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


当前回答

在Windows 7中,将编辑器设置为记事本++

打开任何文本编辑器。打开此文件:C:\Users\YOUR_USERNAME\.gitconfig将此部分添加到底部:


对于64位Notepad++,请使用:

[core]
    editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar

对于32位Notepad++,请使用:

[core]
    editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar

保存并关闭文件。使用git提交时,只需编写gitcommit并按Enter键。它将弹出记事本++。在文件顶部写入提交消息,然后保存并关闭文件。完成!

其他回答

在macOS Big Sur(11.0)测试版上,TextMate:所有环境变量选项都无效。(设置所有三个:GIT_EDITOR、VISUAL和EDITOR。)

最后,在git中设置全局core.editor,这起到了作用:git-config--全局core.editor“~/bin/mate-w”

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

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

对于MAC,BBEdit:

首先,打开BBEdit,单击BBEdit徽标,然后选择Install Command Line Tools。

然后从命令行,

git config --global core.editor "BBEdit -w"

对于Windows,Neovim:

# .gitconfig

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

在Windows 7中,将编辑器设置为记事本++

打开任何文本编辑器。打开此文件:C:\Users\YOUR_USERNAME\.gitconfig将此部分添加到底部:


对于64位Notepad++,请使用:

[core]
    editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar

对于32位Notepad++,请使用:

[core]
    editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar

保存并关闭文件。使用git提交时,只需编写gitcommit并按Enter键。它将弹出记事本++。在文件顶部写入提交消息,然后保存并关闭文件。完成!