如何全局配置git以使用特定的编辑器(例如vim)提交消息?


当前回答

在windows 7中,当添加“Sublime”编辑器时,它仍然给我一个错误:

由于提交消息为空,正在中止提交。

Sublime无法保持焦点。

为了解决这个问题,我打开了c:\users/username/文件夹中的.gitconfig文件,并在单引号外添加了下面一行--wait选项。

[core]
      editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --wait

希望对Sublime面临类似问题的人有所帮助。

其他回答

Mvim作为您的git编辑器

与所有其他GUI应用程序一样,您必须使用wait标志启动mvim。

git config --global core.editor "mvim --remote-wait"

要使Visual Studio代码(vscode)成为默认的git编辑器,请执行以下操作:

git config --global core.editor "code --wait"

对于Windows,Neovim:

# .gitconfig

[core]
    editor='C:/tools/neovim/Neovim/bin/nvim-qt.exe'

在Git配置中设置core.editor:

git config --global core.editor "nano"

设置GIT_EDITOR环境变量:

export GIT_EDITOR=nano

Atom作为您的git编辑器

git config --global core.editor "atom --wait"

需要将Atom配置为从命令行运行,以使上述功能正常工作:OS X:从Atom安装shell命令:菜单栏>Atom>安装Shell命令Windows:不需要任何操作-默认情况下,atom配置为从命令行运行