Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The latest commit gone after hard reset

Tags:

git

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?

like image 517
Eugene Avatar asked Dec 21 '22 08:12

Eugene


1 Answers

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}
like image 109
sehe Avatar answered Jan 03 '23 10:01

sehe