This is a backup of my old blog, some posts may still be usefull.
Check out my Tumblog @ http://pagebakers.nl/

Posted on January 29, 2009

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 ;)

Bookmark and Share
Filed under: Webdevelopment

19 Comments »

  1. Thanks. Last time I just deleted the file, but this is way better.

    19/02/2009 @ 6:17 pmArjen
  2. 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!

    24/03/2009 @ 9:07 amSean
  3. Glad I could help :)

    27/03/2009 @ 3:19 pmEelco Wiersma
  4. [...] 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 [...]

  5. And how you can propagate that change to the remote repository?, so I can share this “ignore” with everybody? :)

    15/07/2009 @ 11:18 pmVlad88SV
  6. @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 :)

    18/07/2009 @ 12:16 amEelco Wiersma
  7. Great solution! Thanks. Now I need to bookmark this page.

    26/11/2009 @ 5:15 pmAndrés Mejía
  8. thanks a lot really helped me, fast and easy…

    15/08/2010 @ 3:12 pmtamik
  9. thanx for the quick tip I learn something new every day.

    31/01/2011 @ 9:31 pmJOsh Beauregard
  10. If you want to find all files that have been added to this list, use the following:

    git ls-files -v|grep ‘^h’

    28/02/2011 @ 7:41 am — Brett Ryan
  11. Thanks a lot, it was very useful

    16/03/2011 @ 8:55 am — Prasad
  12. Good! This what I am looking for. Thank you.

    30/03/2011 @ 5:03 pm — Leong Hean Hong
  13. Thanks! I was trying to remember how to do this.

    22/04/2011 @ 6:52 pm — Gray
  14. Thank you very much!

    16/06/2011 @ 11:05 amsangprabo
  15. [...] 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 [...]

  16. You have written a great post here, do you mind if I link back to you?

    10/09/2011 @ 12:18 ammedical assistant schools
  17. Awesome – thanks for writing this up. Just tried it out and works perfectly.

    22/09/2011 @ 4:56 pm — Jim
  18. :D Thanks so much! Please don’t delete this site! It has tons of great info! :D

    25/10/2011 @ 5:24 pm — hyunjungsoh
  19. [...] git ignoring changes [...]

Leave a comment

CoCre8