Git:取消交互式变基 [英] Git: cancel an interactive rebase

查看:280
本文介绍了Git:取消交互式变基的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢 git rebase -i HEAD〜5 压缩提交内容.有时我认为我需要返回5次提交,但是后来意识到我需要7次提交.但是git已经在vim中调出了rebase编辑器 .git/rebase-merge/git-rebase-todo .

I like to git rebase -i HEAD~5 to squash my commits down. Sometimes I think I need to go back 5 commits but then realize I need 7. However git has already brought up the rebase editor .git/rebase-merge/git-rebase-todo in vim.

如果我退出该缓冲区(vim),那么git会说:

If I quit that buffer (vim) then git says:

Successfully rebased and updated refs/heads/my-branchname

有没有一种方法可以阻止在编辑器中重新定位?我想我可以从另一个shell中进行 git rebase --abort ,但是不确定对中间的 git-rebase-todo 文件有什么作用在另一个缓冲区中进行编辑.

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

推荐答案

您可以通过键入:cq 来使vim退出并使用非零退出代码来取消变基.结果是:

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

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

在vim帮助页面上,我们看到cq是 cquit 的缩写:

From the vim help page we see that cq is short 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.

这篇关于Git:取消交互式变基的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆