How to revert a "git rm -r ."?
git reset HEAD
Should do it. 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
I git-rm'd a few files and went on making changes before my next commit when I realized I needed some of those files back. Rather than stash and reset, you can simply checkout the individual files you missed/removed if you want:
git checkout HEAD path/to/file path/to/another_file
This leaves your other uncommitted changes intact with no workarounds.