Last Updated: February 25, 2016
·
530
· earl3s

Ignore changes in tracked files with git, beyond .gitignore

Sometimes you have generated files or config files in your git repository that you don't want to commit changes to. A common example is a config file for your app. To solve this you might at add it to the .gitignore. However, since it's a tracked file, changes could still be committed by using the -a flag because the file is still tracked.

--assume-unchanged to the rescue.

git update-index --assume-unchanged [file]

You can use --assume-unchanged to tell git that no matter what happens with the file on your machine, assume that no changes have been made. This will solve future merge conflicts and unnecessary file commits later.

You can start looking at changes from files again by running this command:

git update-index --no-assume-unchanged [file]

And you can see all files that have this flag doing this:

git ls-files -v|grep '^h'

Enjoy!