1

I had several commits. I needed to push an old commit but not the newest ones. I used git checkout --hard on an old commit and pushed successfully.

Now I want to get all my work back that I havnt pushed. However I forgot to make a note of the last hash so I dont know what to checkout.

I cant see it with git log (the latest it shows is the commit that i checked out) and I cant see commits that havnt been pushed on github.

Accoring to this link I should be able to see these commits with git reflog, but the newest its showing me is the commit that I checked out. How to get back to the latest commit after checking out a previous commit?

Community
  • 1
  • 1
Evanss
  • 23,390
  • 94
  • 282
  • 505

1 Answers1

1

You need to use git reflog:

git reflog

You will get the sha1 you had before the git reset --hard.

You can see an example in "Undoing a git reset --hard HEAD~1"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250