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

后端 未结 27 2118
庸人自扰
庸人自扰 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 01:56

    In Windows 7, setting editor to Notepad++

    • Open any text editor.
    • Open this file: C:\Users\YOUR_USERNAME\.gitconfig
    • Add this section to the bottom:

    [core]
        editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' 
    
    • Save and close the file.
    • When you're committing with git, just write git commit and press Enter. It will pop open Notepad++.
    • Write your commit message at the top of the file, and save and close the file. Done!

提交回复
热议问题