Git ignore or remove tracked file


If a file is tracked by Git, adding it to .gitignore won’t stop Git from tracking it since .gitignore only applies to untracked files.

To prevent file changes of a .gitignore file from showing up during git status, you can do the following:

  1. Ignore changes
  2. Remove file

Ignore changes

To ignore changes of tracked <file>:

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

To start tracking changes of <file> again:

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

Remove file

To remove tracked file <file>:

git rm --cached <file>
git commit -m 'chore: remove file'


Please support this site and join our Discord!