Completely Cancel a Rebase
I Performed a Rebase Like This: Git Rebase --onto Master New_Background_Processing Export_Background_Processing That Didn't Do What I Wanted It To, So I...
I performed a rebase like this:
git rebase --onto master new_background_processing export_background_processing
That didn't do what I wanted it to, so I performed a reset:
git reset --hard HEAD@{1}
I got my branch back to the state it was, but I received this message when I type git status:
# You are currently rebasing branch 'export_background_processing' on 'e378641'.
How do I cancel that rebase completely? Not sure what that means per se.
4 Answers
Use git rebase --abort. From the official Linux kernel documentation for git rebase:
git rebase --continue | --skip | --abort | --edit-todo | --quit
In the case of a past rebase that you did not properly aborted, you now (Git 2.12, Q1 2017) have git rebase --quit
See commit 9512177 (12 Nov 2016) by Nguyễn Thái Ngọc Duy (pclouds).
(Merged by Junio C Hamano -- gitster -- in commit 06cd5a1, 19 Dec 2016)
rebase: add--quitto cleanup rebase, leave everything else untouchedThere are occasions when you decide to abort an in-progress rebase and move on to do something else but you forget to do "
git rebase --abort" first. Or the rebase has been in progress for so long you forgot about it. By the time you realize that (e.g. by starting another rebase) it's already too late to retrace your steps. The solution is normallyrm -r .git/<some rebase dir>and continue with your life.
But there could be two different directories for<some rebase dir>(and it obviously requires some knowledge of how rebase works), and the ".git" part could be much longer if you are not at top-dir, or in a linked worktree. And "rm -r" is very dangerous to do in.git, a mistake in there could destroy object database or other important data.Provide "
git rebase --quit" for this use case, mimicking a precedent that is "git cherry-pick --quit".
Before Git 2.27 (Q2 2020), The stash entry created by "git merge --autostash" to keep the initial dirty state were discarded by mistake upon "git rebase --quit", which has been corrected.
See commit 9b2df3e (28 Apr 2020) by Denton Liu (Denton-L).
(Merged by Junio C Hamano -- gitster -- in commit 3afdeef, 29 Apr 2020)