Try git reset HEAD yourFile instead of git rm --cached .
A mixed reset will remove your file from the index without deleting it from the working tree.
See " Undo" git add "before commit ."
In your case, git stash should be preceded by git reset , and then git stash pop will restore your changes in the process, after reset.
As for the state <<26> after git rm --cached , this command registers file deletion in the index, which is why you see that it is recorded as โdeletedโ for the next commit.
OP Ferpega insists :
I ask why the remote status exists as a result of git rm --cached , because this command should have the same behavior as git reset HEAD <file> , as you can see in git rm .
Well, no, git rm does not have the same behavior as [ git reset][8] .
Both will affect the index, but:
- one (
git rm ) will write the file for deletion at the next commit, therefore, status <<26>, - the other (
git reset ) will copy HEAD to the index, dropping the specified index back to the file that was in HEAD.
source share