Developing on Staxmanade

How do I undo a bad rebase in Git?

If you use git and leverage the rebase command, you've probably run across a merge issue during the rebase and if you’ve ever felt like, “man, I wish I had a ‘do-over’.

If you’re still in the middle of a rebase it's easy to start over:

git rebase --abort

But let's say you started with this:

image

Did a git rebase and are now looking at:

image

Except you screwed up during a merge conflict and now un-sure how you can get your ‘do-over’.

I was pleasantly surprised at how easy it was. (If you know the key)

Leveraging the git reflog, you can go back in time and check out your branch as though the rebase never happened.

In the following link, I put together a set of steps to create a git repo that puts you into this position (of a bad rebase) and then describes how to get out of it.

https://github.com/staxmanade/GitRebaseReflogFixSample

I'd love to hear any feedback on this repo. Or try submitting a pull request or post a GitHub issue.

Happy Git'ing!