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 --quit
to cleanup rebase, leave everything else untouched
There 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 normally
rm -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)
rebase
: save autostash entry into stash reflog
on --quit
Signed-off-by: Denton Liu
In a03b55530a ("merge
: teach --autostash option", 2020-04-07, Git v2.27.0 -- merge listed in batch #5), the --autostash
option was introduced for git merge
.
(See "Can “git pull
” automatically stash and pop pending changes?")
Notably, when git merge --quit
is run with an autostash entry present, it is saved into the stash reflog.
This is contrasted with the current behaviour of git rebase --quit
where the autostash entry is simply just dropped out of existence.
Adopt the behaviour of git merge --quit
in git rebase --quit
and save the autostash entry into the stash reflog instead of just deleting it.