I am new to git. I have checkout files from remote. I had to delete few files from the git repo. Instead of doing git rm
command, I issued unix rm -rf folder
command. I need to revert the delete command and then perform git rm
command. How to revert to the latest code?
Note: I have not yet committed the staged files.The out out of git status
is the list of files deleted in the below format:
# deleted: i18n/angular-locale_sl.js
# deleted: i18n/angular-locale_in.js
I need to revert the delete command and then perform git rm command. How to revert to the latest code?
Simply do a (since you haven't committed anything):
cd /root/of/your/repo
git checkout HEAD -- .
That will restore the working tree to the index.
(A git reset --hard
should work too, but isn't needed here)
But you could also register those deletion to the index directly:
git add -A .
See "What's the difference between git add .
and git add -u
?"