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

后端 未结 27 2126
庸人自扰
庸人自扰 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:55

    For EmEditor users

    To set EmEditor as the default text editor for Git, open Git Bash, and type:

    git config --global core.editor "emeditor.exe -sp"

    EmEditor v19.9.2 or later required.

    0 讨论(0)
  • 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!
    0 讨论(0)
  • 2020-11-22 01:56

    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

    0 讨论(0)
  • 2020-11-22 01:58

    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"
    
    0 讨论(0)
  • 2020-11-22 01:59

    For IntelliJ users

    When i was trying to git rebase i was getting the following error: 'hint: Waiting for your editor to close the file... code -n -w: code: command not found error: There was a problem with the editor 'code -n -w'.'

    The same error showed up when i was trying to associate IntelliJ with Git:

    The problem was that I did not have the command code added in my environment PATH variable. And i didn't want to use Visual Studio Code from my terminal. So that is why it prompted "command not found". I solved this by deleting

    editor = code -n -w

    from the core section in my .gitconfig file. Git worked properly again.

    0 讨论(0)
  • 2020-11-22 02:00

    To make vim the default editor for git on ubuntu 20:04 run the following command:

    git config --global core.editor vim
    
    0 讨论(0)
提交回复
热议问题