How to undo a Git rollback

Chironex picture Chironex · Jul 6, 2011 · Viewed 7.4k times · Source

I wanted to rollback to the last commit after making a massive error, but I managed to rollback a little too fair. The commit I wanted to reassert doesn't appear when I enter 'git log' in bash (I suppose because it's no longer in the history). Is there any way I can recover the last commit by date?

I'm also using eGit in eclipse for the same project if that makes things easier. Thanks.

Answer

manojlds picture manojlds · Jul 6, 2011

If you are ok with command line, go to you repo, do a git reflog and get the commit which you want to "rollback" to and do a git reset --hard <commit>

You would also be able to do git reset --hard HEAD@{1} and then come back to egit and rollback to the desired commit.