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.

  1. Find the path where your text editor is located by using whereis nameOfTextEditor or find /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/.

  2. 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.

  3. Save and exit. If you have to add the path in Step 2, reload .bashrc by typing source ~/.bashrc if you are using bash, and source ~/.zshrc if you are using zsh.

  4. 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
    
  5. 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.