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

后端 未结 27 2122
庸人自扰
庸人自扰 2020-11-22 01:33

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,

27条回答
  •  醉酒成梦
    2020-11-22 02:10

    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.

提交回复
热议问题