From 9512177b68263085fef84cdbd45ecdee7bfe2377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 12 Nov 2016 09:00:41 +0700 Subject: rebase: add --quit to cleanup rebase, leave everything else untouched MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/ and continue with your life. But there could be two different directories for (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". Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- git-rebase.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index cf60c4390..c62b17863 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -43,6 +43,7 @@ continue! continue abort! abort and check out the original branch skip! skip current patch and continue edit-todo! edit the todo list during an interactive rebase +quit! abort but keep HEAD where it is " . git-sh-setup . git-sh-i18n @@ -239,7 +240,7 @@ do --verify) ok_to_skip_pre_rebase= ;; - --continue|--skip|--abort|--edit-todo) + --continue|--skip|--abort|--quit|--edit-todo) test $total_argc -eq 2 || usage action=${1##--} ;; @@ -402,6 +403,9 @@ abort) finish_rebase exit ;; +quit) + exec rm -rf "$state_dir" + ;; edit-todo) run_specific_rebase ;; -- cgit v1.2.1