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…
thanx for the quick tip I learn something new every day.
If you want to find all files that have been added to this list, use the following:
git ls-files -v|grep ‘^h’
Thanks a lot, it was very useful
Good! This what I am looking for. Thank you.
Thanks! I was trying to remember how to do this.
Thank you very much!
[...] a file in a repository and then assume that the file remains unchanged for any following commits. I stumbled across this blog post which has all of the [...]
You have written a great post here, do you mind if I link back to you?
Awesome – thanks for writing this up. Just tried it out and works perfectly.
:D Thanks so much! Please don’t delete this site! It has tons of great info! :D
[...] git ignoring changes [...]