How do I easily undo a git rebase? A lengthy manual method is:
- checkout the commit parent to both of the branches
- create and checkout a temporary branch
- cherry-pick all commits by hand
- reset the faulty rebased branch to point to the temporary branch
In my current situation, this works because I can easily spot commits from both branches (one was my stuff, the other was my colleague's stuff). However, my approach strikes me as suboptimal and error-prone (let's say I had just rebased with two of my own branches).
Clarification: I am talking about a rebase during which multiple commits were replayed, not only one.
commit:
is what your looking after the HEAD@{#} to reset to. Notrebase:
,reset:
,merge:
orcheckout:
.