Git on Mac: How to set Nano as the default text editor?

76,389

Solution 1

git config --global core.editor "nano"

More information here:

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

Solution 2

If you want to use nano as your editor for all things command line, add this to your bash_profile:

export EDITOR=/usr/bin/nano

This is assuming you're using the system nano. If not, edit to suit where your nano lives (e.g. /usr/local/bin, /opt/local/bin)

Remember to source your bash_profile after setting this or open a new terminal window for the settings to work...

Solution 3

I just learned a moment ago that there (on OSX anyway) is a file at /Users/<USER_NAME>/.gitconfig

$ sudo nano /Users/bob/.gitconfig

Then you should see something like this:

[user]
    email = [email protected]
    name = Bob Sandwich
[core]
    editor = nano
[merge]
    tool = vscode
[mergetool "vscode"]
    cmd = "code --wait "
[diff]
    tool = vscode
[difftool "vscode"]
    cmd = "code --wait --diff  "

After seeing that structure, you can intuitively understand something like (ie: core.editor):

git config --global core.editor "nano"
Share:
76,389

Related videos on Youtube

bad_coder
Author by

bad_coder

Updated on September 18, 2022

Comments

  • bad_coder
    bad_coder over 1 year

    When I'm using Git on Mac and need to do a rebase, the Vim editor kicks in by default. I would prefer Nano – could someone please explain how to reconfigure Git to make it use Nano for rebase?

    • Admin
      Admin over 6 years
      I prefer nano too, I am no masochist.
  • Jorge Orpinel Pérez
    Jorge Orpinel Pérez about 8 years
    That's assuming you use Bash B)
  • Radon Rosborough
    Radon Rosborough over 7 years
    You should be able to use simply export EDITOR=nano.
  • Scott - Слава Україні
    Scott - Слава Україні almost 5 years
    Opening a new terminal window might not be enough to reload .bash_profile.
  • gdibble
    gdibble almost 3 years
    This is manna from cli heaven 😝 🙌 🎉
  • gdibble
    gdibble almost 3 years
    Love the detail here, ty 👍
  • Alexander Skwar
    Alexander Skwar almost 3 years
    WTF are you doing there? "sudo nano <file in your $home>"? And only for reading a file? To which you've got access anyway? How about... "cat <file in your $home>"?