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
find /usr/ -executable -type f -iname "nameOfTextEditor". For the latter, it is usually located in one of these directories, depending on your distro:
Make sure that the path to the location of your text editor is included in the
.bashrcif you are using bash, or in
.zshrcif you are using zsh.
Save and exit. If you have to add the path in Step 2, reload
source ~/.bashrcif you are using bash, and
source ~/.zshrcif you are using zsh.
In order to set the default editor, open
.gitconfigin 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.