re: 10 Common Git Problems and How to Fix Them VIEW POST


However, git rm will remove it from both your staging area, as well as your file system, which may not be what you want.

You can use git rm --cached, which would remove file only from the staging area (the index), while leaving it on filesystem. If you don't remember the command, git status would write it down for you!

Note also that git rm --cached works any time, even after many commits -- it would always make Git no longer track the file, and no longer have it in commits / in the repository, while git reset <file> would work only after you git add-ed the file but before you have created new commit with this new file -- it simply overwrites the state in the staging area (the index) with the state from the latest commit (HEAD); thus if addition was not committed, it would untrack the file (and only then).

code of conduct - report abuse