Joshua Scott
Blog Post

A handy git trick for ignoring local config

I am sure every developer has run into a case where they have accidentally overwritten a config file that worked great on their local development environment, but blows up a live or staging instance. This happened to me recently and I found there are some cases where ignoring a file isn’t an option, so that is why there is “assume-unchanged”.

For a file that you need to be able to change but you want git to “assume” or pretend it isn’t changed, simply do the following in your git directory:

git update-index --assume-unchanged web.config

Then when you want to undo this assumption you can issue the following command:

git update-index --no-assume-unchanged web.config

It’s as easy as that.

Helpful links:

  • http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/
  • https://help.github.com/articles/ignoring-files/
  • http://stackoverflow.com/questions/1753070/git-ignore-files-only-locally
Taggs:
Write a comment