Undoing git remove

git

Solution

Try:

git reset HEAD

If you don't have any uncommitted changes that you care about, then

git reset --hard HEAD

should forcibly reset everything to your last commit. If you do have uncommitted changes, but the first command doesn't work, then save your uncommitted changes with git stash:

git stash
git reset --hard HEAD
git stash pop

To restore all the deleted files in a folder enter the following command.

 git ls-files -d | xargs git checkout --

to check what got deleted try:

git-ls-files --deleted

Problem

I've accidentally executed the following command: ``` git rm -r . ``` Not surprisingly, it removed everything. Is there any way to revert it?

Original source