Default editor for git set to nano--how?

5,170

Solution 1

My wild guess you have set nano as a default system editor, but you can try to update it with

    sudo update-alternatives --config editor

Solution 2

You are missing GIT_EDITOR and core.editor.

ENVIRONMENT AND CONFIGURATION VARIABLES

The editor used to edit the commit log message will be chosen from the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable (in that order).

You set core.editor with ...

git config --global core.editor "vim"
Share:
5,170

Related videos on Youtube

Francesco Marchetti-Stasi
Author by

Francesco Marchetti-Stasi

Updated on September 18, 2022

Comments

  • Francesco Marchetti-Stasi
    Francesco Marchetti-Stasi over 1 year

    New eoan installation, just installed git and vim and recovered one of my projects from backup. Configured git user.email and user.name, made a couple of small changes, tried commit and... nano started. It took me some time to understand how to exit it without committing (BTW I use vim). Neither VISUAL nor EDITOR are set, and the git guide says

    By default, Git uses whatever you’ve set as your default text editor via one of the shell environment variables VISUAL or EDITOR, or else falls back to the vi editor to create and edit your commit and tag messages.

    (https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration).

    Well, I set EDITOR=vi in my profile, but I'd like to understand what's going on here. Any idea?

  • Francesco Marchetti-Stasi
    Francesco Marchetti-Stasi about 4 years
    Yup, that's it--and that's exactly what I wanted to check, to avoid other similar surprises. Many thanks!
  • Francesco Marchetti-Stasi
    Francesco Marchetti-Stasi about 4 years
    No, I didn't miss them, but I wanted to change the editor everywhere, not just for git :)
  • Francesco Marchetti-Stasi
    Francesco Marchetti-Stasi about 4 years
    (anyway I didn't set it, I just found it set that way after a minimal installation...)
  • Dinesh Shekhawat
    Dinesh Shekhawat over 2 years
    I prefer nano so I used this git config --global core.editor "nano"