There may be times when you want to edit some variables in for example a database connection file, to run an application right from within your GIT repo. Of course you don’t wont those changes to be commited, so you add the file the .gitignore.
However adding tracked files to .gitignore won’t work because GIT will still track the changes and commit the file if you use the -a parameter.
Fortunately GIT has a very easy solution for this, just run the following command on the file or path you want to ignore the changes of:
git update-index --assume-unchanged <file>
If you wanna start tracking changes again run the following command:
git update-index --no-assume-unchanged <file>
You can find more info about this in the git manual.
Happy GITting ;)
Thanks. Last time I just deleted the file, but this is way better.
Where were you just two days ago. I was banging my head on the walls to try to find an easy solution like this. Thanks for the trip, definitely use it!
Glad I could help :)
[...] searching for a solution today, I ran across this little gem of an article titled “GIT: ignoring changes in tracked files” from Pagebakers.nl, the salient code is [...]
And how you can propagate that change to the remote repository?, so I can share this “ignore” with everybody? :)
@Vlad88SV
Well.. if you want to accomplish that, you need to add files / directories to .gitignore before they get tracked by git..
let’s say you have a tmp directory in your application and you don’t want to track the files in there, create a .empty (else the tmp dir will not be commited in the repo) file in there, commit it.. then add ‘tmp/*’ in your .gitignore file and commit again. Then it will be shared with other people :)
good luck :)
Great solution! Thanks. Now I need to bookmark this page.
thanks a lot really helped me, fast and easy…