What's the simplest way to undo:
git reset HEAD~
Currently, the only way I can think of is doing a git clone http://...
from a remote repo.
This question is related to
git
Old question, and the posted answers work great. I'll chime in with another option though.
git reset ORIG_HEAD
ORIG_HEAD
references the commit that HEAD
previously referenced.
1.Use git reflog
to get all references update.
2.git reset <id_of_commit_to_which_you_want_restore>
My situation was slightly different, I did git reset HEAD~
three times.
To undo it I had to do
git reset HEAD@{3}
so you should be able to do
git reset HEAD@{N}
But if you have done git reset using
git reset HEAD~3
you will need to do
git reset HEAD@{1}
{N} represents the number of operations in reflog, as Mark pointed out in the comments.
Source: Stackoverflow.com