Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git commit fails with Vim and GVim

Tags:

git

vim

When I try to do a git commit -a, I get a nice vim instance. I type in my message, do :wq, vim closes down and the terminal has the message,

Aborting commit due to empty commit message. 

Pursuant to this question I made sure my core.editor says "gvim" (so does the user.editor, fwiw), but I still get that error message.

Does anyone have another idea?

Edit 1: I am able to commit by specifying a file. My messages are too long to reasonably use the -m option.

Edit 2:

$ git config core.editor vim error: More than one value for the key core.editor: vim error: More than one value for the key core.editor: gvim 

Edit 3: Still having the same problem, even with core.editor sorted. Any other ideas?

$ git config core.editor gvim -f  $ git commit Aborting commit due to empty commit message. 

Edit 4: Other error messages. This is everything I'm seeing. I excluded several from my original question because I've gotten them on many machines, none of which had problems using vim/gvim with git (except the current one). In the case shown here, core.editor is set to vim -f.

$ git commit  (gvim:21655): GLib-WARNING **: g_set_prgname() called multiple times  ** (gvim:21655): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed  ** (gvim:21655): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed  ** (gvim:21655): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed  ** (gvim:21655): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed  ** (gvim:21655): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed Aborting commit due to empty commit message. 

When core.editor is set to gvim -f I get exactly the same error messages except the number is 21641, not 21655. When I Google one of the lines, I get no matches (I find that hard to believe, but there you are).

like image 809
kajaco Avatar asked Sep 21 '10 21:09

kajaco


People also ask

Can I use Vim with git?

Git command works in the command line interface. The vim plugin named fugitive plugin is developed by Tim pope which is used to work with the git tool without terminating the editor. So, vim and git can work together by using the fugitive plugin.


1 Answers

If you are using gvim, you need to make sure that it stays in the foreground, otherwise it will return control to git before you've had a chance to edit and save your message. Specifying the -f switch as part of the editor setting should enable this.

gvim -f 

You have multiple values set for your core.editor setting which is causing a problem. You need to have just one setting.

Try:

git config --global --unset-all core.editor git config --unset-all core.editor git config --global core.editor "gvim -f" 
like image 199
CB Bailey Avatar answered Sep 23 '22 06:09

CB Bailey