如何全局配置git以使用特定的编辑器(例如vim)提交消息?
当前回答
有一个命令列表,您可以使用,但对于vs代码,请使用此命令
git config --global core.editor "code --wait"
这是所有编辑器的链接:https://git-scm.com/book/en/v2/Appendix-C%3A-Git命令设置和配置
其他回答
有一个命令列表,您可以使用,但对于vs代码,请使用此命令
git config --global core.editor "code --wait"
这是所有编辑器的链接:https://git-scm.com/book/en/v2/Appendix-C%3A-Git命令设置和配置
在Git配置中设置core.editor:
git config --global core.editor "nano"
设置GIT_EDITOR环境变量:
export GIT_EDITOR=nano
在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中,将编辑器设置为记事本++
打开任何文本编辑器。打开此文件: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键。它将弹出记事本++。在文件顶部写入提交消息,然后保存并关闭文件。完成!
在Mac OSX 10中将Sublime Text 2设置为Git提交编辑器
运行以下命令:
$ git config --global core.editor "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
或者只是:
$ git config --global core.editor "subl -w"
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 在Vim中如何从“gf”返回
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式