How do you undo a rebase that went wrong after it finished?
IntermediateConceptUndoing changes: reset, revert, restore and reflog
Answer
Use the reflog: the branch moved at each replayed commit, so find the entry just before rebase (start) and reset to it. ORIG_HEAD also works if nothing else has moved it.
git reflog
git reset --hard HEAD@{N} # entry before "rebase (start)"
More on Undoing changes: reset, revert, restore and reflog
What are the three modes of `git reset`?BeginnerWhat is the difference between `git reset` and `git revert`?BeginnerHow do you discard changes in one file?BeginnerHow do you recover a commit after `git reset --hard`?IntermediateCan you recover uncommitted changes lost by `git reset --hard` or `git checkout .`?IntermediateWhat does `git commit --amend` do to the reflog and to the old commit?Intermediate