When using the Git CLI, you might want to set the default text editor to use when writing out your commit messages. This can be set from the .gitconfig
file located in the root of your home directory.
-
Find the path where your text editor is located by using
whereis nameOfTextEditor
orfind /usr/ -executable -type f -iname "nameOfTextEditor"
. For the latter, it is usually located in one of these directories, depending on your distro:/usr/bin/
or/usr/local/bin/
or/usr/share/
. -
Make sure that the path to the location of your text editor is included in the
PATH=
parameter in.bashrc
if you are using bash, or in.zshrc
if you are using zsh. -
Save and exit. If you have to add the path in Step 2, reload
.bashrc
by typingsource ~/.bashrc
if you are using bash, andsource ~/.zshrc
if you are using zsh. -
In order to set the default editor, open
.gitconfig
in your favourite editor and under the section[core]
type the filename of the editor that you want to use (in my case nano) as follows:[core] editor = nano
-
Save the file and exit.
Now, whenever you want to write a long commit message using git commit
, the text editor that you have set in your .gitconfig
should launch with no issues.