Git Setting which editor to use


There are several ways to set which editor to use for committing, rebasing, etc.

  • Change the core.editor configuration setting.

    $ git config --global core.editor nano
  • Set the GIT_EDITOR environment variable.

    For one command:

    $ GIT_EDITOR=nano git commit

    Or for all commands run in a terminal. Note: This only applies until you close the terminal.

    $ export GIT_EDITOR=nano
  • To change the editor for all terminal programs, not just Git, set the VISUAL or EDITOR environment variable. (See VISUAL vs EDITOR.)

    $ export EDITOR=nano

    Note: As above, this only applies to the current terminal; your shell will usually have a configuration file to allow you to set it permanently. (On bash, for example, add the above line to your ~/.bashrc or ~/.bash_profile.)

Some text editors (mostly GUI ones) will only run one instance at a time, and generally quit if you already have an instance of them open. If this is the case for your text editor, Git will print the message Aborting commit due to empty commit message. without allowing you to edit the commit message first. If this happens to you, consult your text editor's documentation to see if it has a --wait flag (or similar) that will make it pause until the document is closed.