0

I was on master branch and i was on some commit i dont remember.

Then i did git pull and i got some 20 more commits.

Now i want to undo that want to go to commit where i was before git pull

user3113427
  • 455
  • 1
  • 6
  • 17

2 Answers2

3

try

git reset --hard HEAD@{1}

it should be previous state of HEAD

ORIG_HEAD is previous state of HEAD, set by commands that have possibly dangerous behavior, to be easy to revert them. It is less useful now that Git has reflog: HEAD@{1} is roughly equivalent to ORIG_HEAD (HEAD@{1} is always last value of HEAD, ORIG_HEAD is last value of HEAD before dangerous operation).

from here: HEAD and ORIG_HEAD in Git

Community
  • 1
  • 1
cnd
  • 32,616
  • 62
  • 183
  • 313
2

Running git reflog will give you a list of all the commits that have been pointed to by HEAD (HEAD is what specifies the current commit you're on e.g. if you're on master then HEAD will be pointing to the most recent commit on master).

It will look something like this:

e6832cb HEAD@{0}: pull: Fast-forward
e251737 HEAD@{1}: checkout: moving from my_branch to master 
bb14227 HEAD@{2}: commit: Here's a comment

If you've just done the git pull and nothing else then the commit you were on before the git pull should be the commit to the left of HEAD@{1}

From there you can use that commit hash to get back to where you want.

Shaun O'Keefe
  • 1,308
  • 1
  • 11
  • 12