Does anybody know how to easily undo a git rebase?
The only way that comes to mind is to go at it manually:
If you successfully rebased against remote branch and can not git rebase --abort
you still can do some tricks to save your work and don't have forced pushes.
Suppose your current branch that was rebased by mistake is called your-branch
and is tracking origin/your-branch
git branch -m your-branch-rebased
# rename current branchgit checkout origin/your-branch
# checkout to latest state that is known to origingit checkout -b your-branch
git log your-branch-rebased
, compare to git log your-branch
and define commits that are missing from your-branch
git cherry-pick COMMIT_HASH
for every commit in your-branch-rebased
remote/your-branch
and you should push only your-branch