Git: cancel interactive reboot

I like git rebase -i HEAD~5 crush my commits down. Sometimes it seems to me that I need to return 5 commits, but then realize that I need 7. However, git has already raised the .git/rebase-merge/git-rebase-todo in vim.

If I exit this buffer (vim), then git says:

 Successfully rebased and updated refs/heads/my-branchname 

Is there a way to stop rebase from w / in editor? I suppose I could git rebase --abort from another shell, but I'm not sure what this will do with the git-rebase-todo file, which I would be in the middle of editing in another buffer.

+6
source share
2 answers

If you are in the window of the initial interactive redirect editor, which looks like this:

 pick f7f3f6d changed my name a bit pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file # Rebase 710f0f8..a5f4a0d onto 710f0f8 ... ... # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. 

you can abort the reinstallation by deleting the entire contents of the editor window and save it or by forcing the editor to close the error code.

In vim, this can be done with d SHIFT+g followed by :wq , or, alternatively, causing the editor to exit with an error, as Mike HP pointed out, using :cq .

If you have already left this window and run the following squash / edits / etc commands, this will not lead to interruption of all redirects, but only to changes to the commands that are currently being edited. At this point, you can kill the editor as described above, but in addition you will have to run git rebase --abort on the command line.

+10
source

You can draw vim output with a non-zero exit code to cancel rebase by typing :cq . The result of this is:

 $ git rebase -i HEAD~4 # enter vim, then type :cq<enter> Could not execute editor 

On the vim help page, we see that cq is abbreviated for cquit :

  *:cq* *:cquit* :cq[uit][!] Quit Vim with an error code, so that the compiler will not compile the same file again. WARNING: All changes in files are lost! Also when the [!] is not used. It works like ":qall!" |:qall|, except that Vim returns a non-zero exit code. 
+6
source

All Articles