Aborting a Rebase
Rebasing in progress feels intimidating — you’re halfway through replaying commits and conflicts are piling up. Fortunately, escape is one command away. git rebase --abort cancels the rebase completely, restoring your branch to exactly the state it was in before you ran git rebase.
When to abort
The conflicts are bigger than expected and you want to think before continuing.
You started the rebase from the wrong base.
You realise the branch should be merged, not rebased.
You broke the golden rule and rebased a shared branch by mistake — abort before pushing.
Tests are failing at intermediate commits and the cleanup will take longer than another approach.
The command
git rebase --abort
That single line cancels the rebase. Your branch returns to the commit it was at before git rebase started, the index is restored, and any conflict markers are gone.
What --abort does
Removes the in-progress rebase state (
.git/rebase-merge/or.git/rebase-apply/).Resets HEAD to the original branch tip.
Resets the index and working directory to match.
Discards any conflict resolutions you’d staged in this rebase.
Confirming the abort worked
git status # On branch feature-x # nothing to commit, working tree clean # (No "interactive rebase in progress" message) git log --oneline -5 # Your branch's pre-rebase commits, in the original order
If --abort doesn’t fully work
Old-school recovery
# When --abort fails or you've gotten very tangled up
git rebase --quit # leaves you wherever HEAD is (no reset)
git reset --hard ORIG_HEAD # reset to where you started
# Or use reflog to find the exact pre-rebase state
git reflog
# pick the entry just before "rebase: ..." and:
git reset --hard HEAD@{<n>}--abort vs --quit
--abort— fully restore the pre-rebase state. The default and safest.--quit— clear the rebase state but leave HEAD/index/working tree as they are. Use only if you know exactly what you want.--skip— drop the current commit and continue replaying the rest. Different from aborting.
Reading the rebase state
Tell whether a rebase is in progress
ls .git/rebase-merge 2>/dev/null && echo "interactive rebase in progress" ls .git/rebase-apply 2>/dev/null && echo "non-interactive rebase in progress" # Or: git status | head -3
Recovering work from an aborted rebase
--abort restores the pre-rebase state. Anything you did DURING the rebase (resolutions, partial fixes) is discarded — but Git keeps it briefly in the reflog. If you decide later you wanted to keep the in-progress work:
git reflog
# Find the HEAD entry for the partial rebase resolution you made
git reset --hard HEAD@{<n>}
# Caution: this could put you back in a half-rebased stateA safe pattern for big rebases
Make a backup branch before rebasing:
git branch backup-before-rebaseDo the rebase.
If it goes well, delete the backup later.
If it goes wrong,
git reset --hard backup-before-rebaseto fully restore.
The safety branch pattern
git switch feature-x git branch backup-before-rebase # marker pointing to current commit git rebase main # do the risky thing # Success: delete the safety net git branch -D backup-before-rebase # Failure: restore git reset --hard backup-before-rebase