如何全局配置git以使用特定的编辑器(例如vim)提交消息?
当前回答
对于emacs用户
.emacs:
(server-start)
外壳:
export EDITOR=emacsclient
其他回答
在windows 7中,当添加“Sublime”编辑器时,它仍然给我一个错误:
由于提交消息为空,正在中止提交。
Sublime无法保持焦点。
为了解决这个问题,我打开了c:\users/username/文件夹中的.gitconfig文件,并在单引号外添加了下面一行--wait选项。
[core]
editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --wait
希望对Sublime面临类似问题的人有所帮助。
在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:
只需尝试EDITOR=vim-gitcommit。
或者可以通过在bashrc中导出EDITOR=vim将EDITOR设置为vim。
在Git配置中设置core.editor:
git config --global core.editor "nano"
设置GIT_EDITOR环境变量:
export GIT_EDITOR=nano
如果你正在使用命令行与设计师合作,那么Pico,而且不知道捷径;)
git config --global core.editor "pico"
Or
export VISUAL=pico
export EDITOR=pico
推荐文章
- 如何更改Git日志日期格式
- 如何在Vim注释掉一个Python代码块
- git pull -rebase和git pull -ff-only之间的区别
- GitHub -致命:无法读取用户名https://github.com':没有这样的文件或目录
- 撤消git平分错误
- 使用.gitconfig配置diff工具
- 如何配置Mac OS X术语,使git有颜色?
- Visual Studio Code: .git文件夹/文件隐藏
- “node_modules”文件夹应该包含在git存储库中吗
- 如何在可视块模式插入?
- 为什么git-rebase给了我合并冲突,而我所做的只是压缩提交?
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 如何从远程分支中挑选?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?