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.
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.
If you accidentally did
git rm -rf .
and removed all, you can recover it doing this.
git status
git reset HEAD .
git checkout -- .
first do git status to see what files you have deleted.
second reset the HEAD to unstage all the files with git reset HEAD .
lastly, you can restore all the files by doing git checkout -- .
If you accidentally delete the file using git delete command 'rm' and want to recover, then use the command :
git reset HEAD^<filename>
to recover the file