I supposed to delete another file with git rm abc.c
. But I deleted a wrong one.
How can I recover it?
Right now, when I issue git status
, it says
deleted: abc.c
BTW, I have other uncommitted changes now.
You need to do two commands, the first will "unstage" the file (removes it from the list of files that are ready to be committed). Then, you undo the delete.
If you read the output of the git status
command (after the using git rm
), it actually tells you how to undo the changes (do a git status after each step to see this).
Unstage the file:
git reset HEAD <filename>
Restore it (undo the delete):
git checkout -- <filename>