4

I commited my changes and didn't push them to the server. Then I did hard reset to one of my previous commits and my latest commit gone. Does it mean commits which weren't pushed to server gone after hard reset?

edit: Is it possible to recover my latest commit?

Eugene
  • 59,186
  • 91
  • 226
  • 333

1 Answers1

11

Yes, but not immediately. Reflog entries will expire in time and the contents will disappear on garbage collection.

You can still get them back from the reflog:

git reflog

and reset to them/checkout:

git reset HEAD@{1}

or, e.g. checking it out to a rescue branch:

git checkout -b rescue HEAD@{1}
sehe
  • 374,641
  • 47
  • 450
  • 633