Reputation: 2567
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).
Upvotes: 34
Views: 11039
Reputation: 43563
Consider using the fugitive git plugin for vim.
You can perform the most often-used git command straight from (g)vim.
Upvotes: 0
Reputation: 160
I had come across a similar error.
Running a :wq
or :q!
would exit with issues. I have tried other editors (TextMate) and upon save and exit of that editor, the commit would complete.
Found that when closing the document with :x
the commit would close without having to move to gvim and all the configuration that was needed there.
Summary -
:x
was my answer.
Upvotes: 0
Reputation: 2832
Using gvim -f
should be the solution (works for me), but simply setting core.editor
may not necessarily cause git to use it. To find out what git is actually using, run git var GIT_EDITOR
. It should print gvim -f
. If not, check man git-var
and jump to the section on the GIT_EDITOR
variable to find out what could be overriding your core.editor
setting.
Upvotes: 6
Reputation: 793249
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"
Upvotes: 76
Reputation: 333294
Are you prefixing the lines in your commit message with #
? If you are, Git will treat those as comment lines, ignore them, and find no content in your message.
Upvotes: 4