Exclude modified files in git
Published at August 30th 2021
There might be times when you want to change some files, but don't want them to show up under changed files, when you do
git status or in your Git GUI client.
You can use the following command to tell git to ignore any changes to the file:
git update-index --assume-unchanged <file>
To undo the ignore, just run the following command:
git update-index --no-assume-unchanged <file>
You can also alias the command by adding the following lines in your
[alias] ignore = update-index --assume-unchanged noignore = update-index --no-assume-unchanged
Now you can just use
git ignore <file> and
git noignore <file> to ignore and undo ignore respectively.