V
V
Voldemar Duletsky2012-10-17 13:00:31
git
Voldemar Duletsky, 2012-10-17 13:00:31

.gitignore and tracked files

It so happened that the site config is stored in the repository, and if any changes are made to it (for example, adding routes), then the local version of the site stops working for other programmers, since the connection parameters to the database are different for everyone.

As a solution, I tried to add it to .gitignore, but when I commit, the config is still displayed in the list of modified files. Is it possible to somehow prevent tracking changes in the config without removing it from the repository?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
akira, 2012-10-17
@r00t_aka_spin

You can temporarily ignore changes in the file with the command: git update-index --assume-unchanged <file>
Disabled with the command: git update-index --no-assume-unchanged <file>

G
Gleb Starkov, 2012-10-17
@colonel

You need to remove it from the index:
git rm --cached path/to/file

N
nick4fake, 2012-10-17
@nick4fake

It's just that it's already in the repository. do a git rm and it won't update anymore.

M
Monnoroch, 2012-10-17
@Monnoroch

You must have made a mistake when adding it to .gitignore, otherwise it would not appear in the list of modified files. If you show how you did it, maybe they can help you here.

D
DorBer, 2012-10-17
@DorBer

We have several levels of inherited configs in our project. Those that are used by each developer are prefixed with local. These files are added to .gitignore. Templates for local configs are stored in the repository with the sample extension. The same local configs are convenient for staging.

W
winbackgo, 2012-10-17
@winbackgo

You can make the congig.local.php file add it to .gitignore and at the bottom of inc.config.php write something like

 if (is_file($local_config = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'congig.local.php'))
     include $local_config;

This is not quite an answer to the question (it already was), but from experience I know that it is much more convenient to change configs this way, especially if the site is on several servers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question