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

104

27

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?

Thank you!

Dimitri Vorontzov

Posted 2012-11-08T23:15:05.883

Reputation:

3I prefer nano too, I am no masochist. – Rolf – 2017-09-22T10:31:14.027

Answers

167

git config --global core.editor "nano"

More information here:

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

sunnyrjuneja

Posted 2012-11-08T23:15:05.883

Reputation: 1 786

30

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

phildobbin

Posted 2012-11-08T23:15:05.883

Reputation: 401

That's assuming you use Bash B) – Jorge Orpinel – 2016-03-25T23:09:32.643

3You should be able to use simply export EDITOR=nano. – Radon Rosborough – 2016-10-18T03:20:57.963

Opening a new terminal window might not be enough to reload .bash_profile. – Scott – 2019-07-25T04:40:40.807

1

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 = bob@sandwich.net
    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"

agm1984

Posted 2012-11-08T23:15:05.883

Reputation: 121