How do I make Git use the editor of my choice for

2018-12-31 06:09发布

I would prefer to write my commit messages in Vim, but it is opening them in Emacs.

How do I configure Git to always use Vim? Note that I want to do this globally, not just for a single project.

19条回答
谁念西风独自凉
2楼-- · 2018-12-31 06:45

For Windows users who want to use Kinesics Text Editor

Create a file called 'k.sh', add the following text and place in your home directory (~):

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

At the git prompt type:

git config --global core.editor ~/k.sh
查看更多
无色无味的生活
3楼-- · 2018-12-31 06:47

Just try EDITOR=vim git commit.

Or you can set your EDITOR to vim by export EDITOR=vim in your bashrc.

查看更多
深知你不懂我心
4楼-- · 2018-12-31 06:49

Atom as your git editor

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

Atom needs to be configured to run from the command line for the above to work:

OS X: install shell commands from Atom: menu bar > Atom > Install Shell Commands

Windows: no action required - atom is configured to run from the command line by default

查看更多
旧时光的记忆
5楼-- · 2018-12-31 06:49

For Textmate Users

This opens Textmate editor in when you want to edit your commits. Requires textmate command line tools to be installed.

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

查看更多
冷夜・残月
6楼-- · 2018-12-31 06:50

Setting Sublime Text 2 as Git commit editor in Mac OSX 10

Run this command:

$ git config --global core.editor "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"

Or just:

$ git config --global core.editor "subl -w"
查看更多
姐姐魅力值爆表
7楼-- · 2018-12-31 06:52

Windows: setting notepad as the default commit message editor

git config --global core.editor notepad.exe

Hit Ctrl+S to save your commit message. To discard, just close the notepad window without saving.

In case you hit the shortcut for save, then decide to abort, go to File->Save as, and in the dialog that opens, change "Save as type" to "All files (*.*)". You will see a file named "COMMIT_EDITMSG". Delete it, and close notepad window.

Edit: Alternatively, and more easily, delete all the contents from the open notepad window and hit save. (thanks mwfearnley for the comment!)

I think for small write-ups such as commit messages notepad serves best, because it is simple, is there with windows, opens up in no time. Even your sublime may take a second or two to get fired up when you have a load of plugins and stuff.

查看更多
登录 后发表回答