René Link René Link - 4 months ago 20
Git Question

How to abort a git rebase in interactive editor

When I do an interactive rebase, e.g.

git rebase -i HEAD~3


the rebase interactive editor (vim in my case) opens to let me edit the commits to rebase

pick c843ea2 Set Vim column limit to 80 (OS X)
pick fc32eac Add Bash alias for `pbcopy` (OS X)
....


If I now decide that I want to abort the rebase and quit vim using
:q
the rebase starts anyway. I'm using git version
1.9.0.msysgit.0
on windows.

Sure I can just delete all
pick
lines, but it might be a lot to do if I rebase a longer history. Is there another way?

How can I quit the rebase interactive editor (vim) and abort the rebase?

Answer

You can use:

:%d|x

This tells Vim to delete all lines (:%d) and then (bar |) save and quit (:x).

Git will print a comforting:

Nothing to do