Git tip of the day: ‘git reflog’ or How to undo a git rebase?

Today I messed things up quite a bit in doing an interactive rebase (git rebase -i [COMMIT_ID]). Argh, what to do now after creating all those commits now for the last hours?

The good thing is, nearly always someone else run into this issue already and the search result for ‘git undo rebase’ included as first hit the solution for me.

Use git reflog to find the action before your rebase:

git reflog

Then pick the action you want to go back to and reset to it:

git reset --hard HEAD@{5}

Tags:

One Response to “Git tip of the day: ‘git reflog’ or How to undo a git rebase?”

  1. Martin Pitt says:

    Am I the only one that read that as “re-flog” the first time? :-)

    Thanks for the hint!