Mac OS X restore files deleted by git rm

2019-08-27 23:54发布

问题:

i just messed up big. The way it happened is so emberassing that I won't write it down :)

So here's my problem:

  • Github Repop deleted
  • Local repo files delete by git rm -r
  • Local repo new initalized

Is there any chance how to restore my data? Luckily it's in a very very early stage of this project.

Regards

回答1:

git reset HEAD

If you don't have any uncommited changes you care about then use

git reset --hard HEAD


回答2:

I am not sure I completely understand the state of your local repo, but if all you did was a git rm -r * and committed that, then everything is still there. You can just reset to the previous commit:

git reset --hard HEAD~1


标签: git restore rm