How do I remove a file from a git repositorie's index without removing the file from the working tree?

If I had a file ./notes.txt that was being tracked by git, I could run git rm notes.txt. But that would remove the file. I'd rather want git just to stop tracking the file.


You could just use git rm --cached notes.txt. This will keep the file but remove it from the index.


git reset HEAD <file> for removing a particular file.

and git reset HEAD for removing all files from the git index.

  • That answer appeared 8 years after Gert's solution, has semantic of git reset command changed since that time? – Kamil Apr 26 '19 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.