3

At first I want to select some commits into into squash,

But I did something wrong ,

How could I abort rebase this time, Because If I type 'qa!' to quit the vim editor, it'll also do the rebase. I don't want it.

enter image description here

newBike
  • 14,385
  • 29
  • 109
  • 192
  • possible duplicate of [How to abort an interactive rebase if --abort doesn't work?](http://stackoverflow.com/questions/5104649/how-to-abort-an-interactive-rebase-if-abort-doesnt-work) – Makoto May 25 '14 at 03:03
  • @Makoto I disagree that this is a duplicate, the linked question and this question deal with slightly different situations, and the answer on the linked question isn't really the right approach. –  May 25 '14 at 03:12
  • It might be a duplicate of this: http://stackoverflow.com/questions/16595908/git-exit-vim-without-commiting – jcm May 25 '14 at 13:24
  • `:q!` worked for me, it said `successfully rebased`, but actually it did nothing. – itsjavi May 18 '16 at 10:04

1 Answers1

9

You didn't really provide a enough information about where in the rebase process you are, but based on your screenshot, I'm guessing that you've already gotten past the rebase editor part:

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

and that you're already in the middle of squashing some commits. Notice that the editor says the following:

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

"An empty message aborts the commit". So just leave an empty message, save, and quit your editor (which is :wq if you're using Vim).

Then you'll be dropped out of the commit dialog, but you'll still be in the middle of the 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) $

Now just simply use the --abort flag to finish aborting the rebase:

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