Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT un-rollback a commit

Tags:

git

I did a commit and push on my git repo.

I then needed to rollback that commit which I did like this:

git reset --hard b1b5768c9687455f01bab242ff177a5ee403104f

Is it possible to find the SHA of the first commit? and go back to it again?

like image 769
bob Avatar asked Feb 20 '26 21:02

bob


1 Answers

Use git log -g or git reflog to see the reflog -- the log of all of the values that a given HEAD has taken on. Think of it as a chronological history of HEAD rather than a checkin history.

Once you find it you can git reset back to it (possibly after creating a branch specifically to point to it) or cherry pick part of it that you want.

like image 82
Ben Jackson Avatar answered Feb 22 '26 11:02

Ben Jackson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!