How do I restore files that were deleted accidentally with `git rm .`?

Viewed 1098

I just made a stage with:

git add .

When I wanted to reset, I used:

git rm .

Suddenly all the files are deleted!! I thought that it should be just the tree-working deleted, it acted like I did :

rm -rf ./*

Why did it delete all the files? And what command should I have used instead?

4 Answers

All this reset did not work for me, and how I was scared! My situation: I had an empty repository and I had made 4 commits. What I needed to do was to go to a specific commit before the git rm took effect. So in my case, if the above does not work, try:

git log
git checkout <your-before-git-rm-commit>
Related