What is the difference between git rm --cached and git reset <file>?
According to the git rm documentation ,
--cached Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone. But according to this resource, file uninstallation is done using
git reset HEAD <file> What is the difference? There is one?
With git rm --cached you create a file for deletion, but you do not delete it from the working directory. Then the file will be shown as unplayed.
Take a test drive
git init test_repo cd test_repo touch test git add test git commit -m 'Added file test git rm --cached test git status Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: test <---- staged for removal Untracked files: (use "git add <file>..." to include in what will be committed) test <-- still in the working dir With git reset <file> you can disable the file. In the above example, you can use git reset test to cancel the deletion.
git reset test git status On branch master nothing to commit, working directory clean git rm --cached removes the file from the index, but leaves it in the working directory. This indicates to Git that you no longer want to track the file.
git reset HEAD leaves the file as a tracked file in the index, but changes cached in the index are lost. This has the effect as if the file in the cache was written above the file in HEAD (and the working tree file is not touched)