Chinaunix首页 | 论坛 | 博客
  • 博客访问: 179046
  • 博文数量: 27
  • 博客积分: 2774
  • 博客等级: 少校
  • 技术积分: 250
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-31 11:00
文章分类

全部博文(27)

文章存档

2011年(2)

2010年(5)

2009年(10)

2008年(3)

2007年(7)

分类:

2010-05-04 13:17:44

8th April 2010

I have had an annoying problem with git and vi. I like to use vim to edit my commit messages, but I’ve been hit with this annoying message every time I write the message and quit vim.

error: There was a problem with the editor 'vi'

After a little bit of digging I found that this message is shown by git when the editor exits with a non-zero exit code. You can use $? to see the exit code of last script or application.

$ vim     # then exit vim with :q immediately
$ echo $?
1

I’m still not sure why vim is exiting with non-zero exit code, but it is definitely related to my .vimrc - moving it to .vimrc.bak seemed to fix the problem. I’m using the excellent  plugin to manage my vimfiles, so I plan to go through that and my installed plugins to find the cause of the problem.

There is a fix though, I’m not sure what’s causing this, but I found a  which shows this:

$ vim          # and exit with :q
$ echo $?
1
$ /usr/bin/vim # and exit with :q
$ echo $?
0
$ which vim
/usr/bin/vim

Running vim with /usr/bin/vim seems to make it exit cleanly. So to fix the problem with git commit you just need to run this:

$ git config --global core.editor /usr/bin/vim

I’d still like to get to the root of the problem, but this gets me my git commit messages back!

阅读(4463) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~