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


当前回答

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

git config --global core.editor "pico"

Or

export VISUAL=pico
export EDITOR=pico

其他回答

要使vim成为ubuntu 20:04上git的默认编辑器,请运行以下命令:

git config --global core.editor vim

只需尝试EDITOR=vim-gitcommit。

或者可以通过在bashrc中导出EDITOR=vim将EDITOR设置为vim。

Atom作为您的git编辑器

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

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

在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: 

对于MAC,BBEdit:

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

然后从命令行,

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