Git ignore already modified files

March 18, 2020

I encounter a rare scenario that there is a file modified, but I don’t want to commit this change on git. There are many ways to do such as .gitignore file, but it doesn’t work when the file already tracks.

The solution here is to manually ignore the file by entering this command:

git update-index --assume-unchanged <file path>

To start tracking again, revert by using this command:

git update-index --no-assume-unchanged <file path>

Feel free to reach out if you have any questions.

Originally published at on March 18, 2020.

Written by Victor Leung who is a keen traveller to see every country in the world, passionate about cutting edge technologies. Follow me on Twitter