当VI在屏幕上等待提交消息时,如何停止Git提交? [英] How do I stop a Git commit when VI is on the screen waiting for a commit message?

查看:85
本文介绍了当VI在屏幕上等待提交消息时,如何停止Git提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾要求Git在git bash中执行一次提交,它提供了VI,因为它总是这样。



我现在希望取消提交,如何我从这一点防止继续进行提交?

解决方案

您有两种选择:


  • 提供一个空的提交消息。如果它是一个新的提交,并且您还没有保存该消息,则可以简单地使用:q!(退出而不保存)。如果您已经保存(或者您正在修改之前的提交),只需删除整个日志消息并再次保存即可。这可以在Vim中使用 ggdG + :wq 来完成。

  • 让编辑器以非零退出代码退出。在Vim中,你可以使用:cq (以错误代码退出)。 b $ b

    值得注意的是,您始终可以将工作副本重置为在提交 git reset HEAD ^ 之前的状态。


    I have asked Git to perform a commit from within git bash, It has brought up VI as it always does.

    I now wish to cancel the commit, how do I prevent proceeding with the commit from this point?

    解决方案

    You have two options:

    • Provide an empty commit message. If it's a new commit and you haven't yet saved the message, you can simply use :q! (quit without saving). If you’ve already saved (or you're amending a previous commit), just delete the entire log message and save again. This can be done with ggdG + :wq in Vim.

    • Have the editor exit with a non-zero exit code. In Vim, you can use :cq (quit with an error code).

    It's worth noting that you can always reset your working copy to the state it was in before the commit with git reset HEAD^.

    这篇关于当VI在屏幕上等待提交消息时,如何停止Git提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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