我更愿意在Vim中编写提交消息,但它在Emacs中打开它们。
如何配置Git以始终使用Vim?请注意,我想在全球范围内执行此操作,而不仅仅是针对单个项目。
我更愿意在Vim中编写提交消息,但它在Emacs中打开它们。
如何配置Git以始终使用Vim?请注意,我想在全球范围内执行此操作,而不仅仅是针对单个项目。
如果要设置编辑器 只要 对于Git,要么(你不需要两者):
core.editor
在你的Git配置中: git config --global core.editor "vim"
GIT_EDITOR
环境变量: export GIT_EDITOR=vim
如果你想为Git设置编辑器 以及其他计划,设定标准化 VISUAL
和 EDITOR
环境变量*:
export VISUAL=vim
export EDITOR="$VISUAL"
*不一定需要设置两者,但某些程序可能不会使用更正确的 VISUAL
。看到 VISUAL
与 EDITOR
。
对于Sublime Text:
将此添加到 .gitconfig
。该 --wait
很重要(它允许在sublime中键入文本并等待save / close事件。
[core]
editor = 'subl' --wait
'subl'可以替换为可执行文件的完整路径,但通常在正确安装时可用。
复制粘贴:
git config --global core.editor "vim"
如果您想知道自己在做什么。从 man git-commit
:
环境和配置变量
用于编辑提交日志消息的编辑器将从中选择
GIT_EDITOR
环境变量,core.editor
配置变量,VISUAL
环境变量,或EDITOR
环境变量(按此顺序)。
在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:
在Windows 7中,在添加“Sublime”编辑器时它仍然给我一个错误:
由于空提交消息而中止提交。
Sublime无法保持专注。
为了解决这个问题,我在c:/ users / username /文件夹中打开了.gitconfig文件,并在双引号外添加了以下行--wait选项。
[core]
editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --wait
希望它对Sublime面临类似问题的人有所帮助。
C:\Users\YOUR_USERNAME\.gitconfig
[core]
editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe'
git commit
并按 Enter
。它将弹出Notepad ++。如果你正在与使用命令行的设计师合作,那么Pico,并且不知道捷径;)
git config --global core.editor "pico"
要么
export VISUAL=pico
export EDITOR=pico
运行此命令:
$ git config --global core.editor "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
要不就:
$ git config --global core.editor "subl -w"
使Visual Studio代码(vscode)成为您的默认git编辑器
git config --global core.editor "code --wait"
git config --global core.editor "atom --wait"
需要将Atom配置为从命令行运行以使上述工作:
OS X.:从Atom安装shell命令:菜单栏> Atom> 安装Shell命令
视窗:无需任何操作 - 默认情况下,atom配置为从命令行运行