如何在选择操作后中止交互式rebase

时间:2014-05-25 02:51:54

标签: git

首先,我想选择一些提交到壁球中,

但我做错了什么,

这次我怎么能中止rebase, 因为如果我输入' qa!'要退出vim编辑器,它也会进行rebase。我不想要它。

enter image description here

1 个答案:

答案 0 :(得分:7)

您实际上没有提供足够的信息,说明您在rebase过程中的位置,但根据您的屏幕截图,我猜测您已经超越了rebase编辑器部分:

pick c843ea2 Set Vim column limit to 80 (OS X)
pick fc32eac Add Bash alias for `pbcopy` (OS X)
pick 7b9dbdd Add foo.txt for test
pick 5e45c82 Add doop.txt

# Rebase 320ed55..5e45c82 onto 320ed55
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

并且你已经在挤压一些提交了。请注意,编辑说如下:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.

“空消息会中止提交”。所以只留下一条空信息,保存并退出编辑器(如果您使用的是Vim,则为:wq。)

然后你将退出提交对话框,但你仍然会在rebase的中间:

(master) $ git rebase -i head~4
Aborting commit due to empty commit message.

Could not apply 5e45c82a85818bd05e7fce3844ec720a8f99a418... Add doop.txt

(master|REBASE-i 4/4) $

现在只需使用--abort标志即可完成中止rebase:

(master|REBASE-i 4/4) $ git rebase --abort
(master) $