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


当前回答

Atom作为您的git编辑器

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

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

其他回答

如果你正在使用命令行与设计师合作,那么Pico,而且不知道捷径;)

git config --global core.editor "pico"

Or

export VISUAL=pico
export EDITOR=pico

对于希望使用Kinetics文本编辑器的Windows用户

创建一个名为“k.sh”的文件,添加以下文本并放置在主目录(~)中:

winpty "C:\Program Files (x86)\Kinesics Text Editor\x64\k.exe" $1

在git提示符下键入:

git config --global core.editor ~/k.sh

在Ubuntu和Debian(谢谢@MichielB)上,也可以通过运行以下命令来更改默认编辑器:

sudo update-alternatives --config editor

这将提示以下内容:

There are 4 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
* 3            /usr/bin/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    10        manual mode

Press enter to keep the current choice[*], or type selection number: 

有一个命令列表,您可以使用,但对于vs代码,请使用此命令

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

这是所有编辑器的链接:https://git-scm.com/book/en/v2/Appendix-C%3A-Git命令设置和配置

对于MAC,BBEdit:

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

然后从命令行,

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