Git提交的消息被vi丢失 [英] Git commit messages lost by vi

查看:72
本文介绍了Git提交的消息被vi丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个笨拙的打字员,我不经常使用vi/vim,但是我确实将它用于提交消息.但是,如果在编辑提交消息(例如,:Wq,而不是:wq)时键入错误的命令,则当您使用:wq:x在vim中正确关闭提交消息时,将得到以下信息:

I'm a clumsy typist, and I don't use vi/vim very often, but I do use it for commit messages. However, if you type a wrong command while editing a commit message (:Wq, say, instead of :wq), when you correctly close out the commit message in vim with :wq or :x, you get this:

error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

通常,像:W这样的错误命令是没有问题的-vim只会忽略它,您可以继续使用该文件并保存它,但是在git commit消息中,一旦输入错误,我将无法撤消地丢失提交消息.

Normally, a wrong command like :W is no problem—vim just ignores it and you can keep on working with the file and save it, but in git commit messages as soon as I mistype, I have irrevocably lost the commit message.

这是怎么回事,我该如何解决? (通过Homebrew使用git 1.9.1,以及与OS X 10.9一起打包的vim 7.3)

What's going on here, and how do I fix it? (Using git 1.9.1 via homebrew, vim 7.3 as packaged with OS X 10.9)

推荐答案

您应该将vim设置为不脱离shell并位于前台.您可以使用以下命令执行此操作:

You should set vim to not detach from the shell and be in the foreground. You can do this with the following command:

git config --global core.editor vim -f

从男人那里来:

   -f          Foreground.  For the GUI version, Vim will not fork and detach from the shell it
               was  started in.  On the Amiga, Vim is not restarted to open a new window.  This
               option should be used when Vim is executed by a program that will wait  for  the
               edit  session  to  finish (e.g. mail).  On the Amiga the ":sh" and ":!" commands
               will not work.

这篇关于Git提交的消息被vi丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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