Ignore (without committing) locally deleted files tracked by Git

I need to delete a file from the file system that is tracked by the Git repository, and I want to leave this file in the Git repository unchanged (no commit for the repo). This is easy for a locally modified file where I use an optional update index option and it works fine. I need the same behavior for deleted files.

I tried this without success:

  • git update-index --assume-unchanged <file>
  • Add file to .git/info/exclude
+3
source share
1 answer

If you run git update-index --assume-unchanged <file>before deleting the file, this will work. eg.

$ git update-index --assume-unchanged <file>
$ rm <file>
$ git status
# On branch master
nothing to commit, working directory clean
+2
source

All Articles