当我尝试执行 git commit -a
时,我得到了一个很好的 vim 实例。我输入我的消息,执行 :wq
,vim 关闭并且终端有消息,
Aborting commit due to empty commit message.
根据this question我确保我的 core.editor 显示“gvim”(user.editor 也是如此,fwiw),但我仍然收到该错误消息。
还有人有其他想法吗?
编辑 1:我能够通过指定文件来提交。我的消息太长,无法合理使用 -m 选项。
编辑 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
编辑 3: 仍然有同样的问题,即使 core.editor 已排序。还有其他想法吗?
$ git config core.editor
gvim -f
$ git commit
Aborting commit due to empty commit message.
编辑 4:
其他错误信息。这就是我所看到的一切。我从我原来的问题中排除了几个,因为我已经在很多机器上得到了它们,其中没有一个在使用 vim/gvim 和 git 时有问题(当前的除外)。在此处显示的情况下,core.editor 设置为 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.
当 core.editor 设置为 gvim -f
时,我得到完全相同的错误消息,除了数字是 21641,而不是 21655。当我谷歌其中一行时,我没有找到匹配项(我很难相信,但你就是这样)。
最佳答案
如果您正在使用 gvim,您需要确保它位于前台,否则它会在您有机会编辑和保存消息之前将控制权返回给 git。将 -f
开关指定为编辑器设置的一部分应该可以启用此功能。
gvim -f
您为导致问题的 core.editor
设置设置了多个值。您只需要一个设置。
尝试:
git config --global --unset-all core.editor
git config --unset-all core.editor
git config --global core.editor "gvim -f"
关于Vim 和 GVim 的 Git 提交失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3764481/