How to undo a git rebase
Given the following situation:
- You’re on
feature/*branch and you have your latest changes already pushed to
- Now, you want to rebase your
feature/*branch with the latest
- You type in
git rebase masterfrom your
- You fix all conflicts and finish the rebase
- OH SHIT SOMETHING’S WRONG I NEED TO UNDO IT BUT HOW?
Okay, take a deep breath and just calm down. Use the following to reset it to your latest origin.
$~ git reset --hard ORIG_HEAD
That’s it. This will only work if you haven’t push your changes to
origin yet. If you have, then you need to use