You need to make two commands, the first one will “not erase” the file (removes it from the list of files that are ready for fixing). Then you delete the deletion.
If you read the output of the git status command (after using git rm ), it will actually tell you how to discard the changes (execute the git status after each step to see this).
Poor file:
git reset HEAD <filename>
Restore it (cancel deletion):
git checkout -- <filename>
source share