Stuck in a git rebase ... how to reset
I somehow got my repo into the same state. In my case, there was no .git/rebase-merge
directory, but I did find a rebase-apply
directory. Other than the in-progress rebase, git status
was clean, so the only thing I needed to do to get out of the weird bad rebase state was to run:
rm -rf .git/rebase-apply/
To escape from corrupted git rebase
you can do the following
- Reset to a known state. You can find out from which commit you started your
rebase
withgit reflog
.
For example, reflog
will give you the following. The rebase starting point is the last rebase (start)
or rebase -i (start)
if you did an interactive rebase. Here it is HEAD@{1}
:
$ git reflog
f10ccfed (HEAD) HEAD@{0}: rebase : fast-forward
383aa038 (origin/master, origin/HEAD) HEAD@{1}: rebase (start): checkout HEAD~10
0600cf7e (origin/Files, master, Files) HEAD@{4}: checkout: moving from master to Files
0600cf7e (origin/Files, master, Files) HEAD@{5}: commit: fixes
f10ccfed (HEAD) HEAD@{6}: commit: refactoring
So what you need is:
git checkout master # assuming you were on master
git reset --hard HEAD@{1}
- Remove the
rebase-merge
folder
rm -rf .git/rebase-merge
git rebase --quit
worked for me.