简体   繁体   中英

git is not ignoring files from the mentioned folder in .gitignore

in our project, the config files are stored into /application/config/ folder. In the .gitignore file we have that path mentioned so that our local configuration files do not get pushed to the server. But every time we change the contents of any file in /application/config/ folder, git is tracking the changes. We have tried this command git rm --cached name_of_file . While it stopped tracking the changes from the local, after pushing it also deleted the respective file from the server as well. Any help would be appreciated.

gitignore is not used for files that are already pushed upstream. This is used for files that are in your local folders but you don't want to commit or push them.

You need to first do git rm for all these files, commit them and push the delete upstream. Then create these files again in your local folders. Post that, gitignore will ignore these files

This is a common mistake to make when using git , or source control in general. Generally speaking, source control should only be employed on files that will be the same everywhere , such as source code. If a file needs to be created/modified for different targets (like a config file on different servers), then rather than versioning the config file, you should version some code that generates it .

As has been mentioned elsewhere, use git rm to stop tracking the files. Then you should dedicate some time (it likely won't take too long; a few hours is usually sufficient) towards creating a solution to autogenerate them, with possible manual tweaking (but this should be avoided, for obvious reasons).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM