There are several ways to set which editor to use for committing, rebasing, etc.
core.editor
configuration setting.git config --global core.editor nano
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
VISUAL
or EDITOR
environment variable. (See [VISUAL
vs EDITOR
](https://unix.stackexchange.com/questions/4859/visual-vs-editor-whats-the-difference).)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.