Trouble on setting the git 'core.editor'

The easiest way is to change the environment variable EDITOR to point to mate. In your .bash_profile add the following:

export EDITOR="/usr/local/bin/mate -w"

and re-start your terminal session, or source the .bash_profile.

As for your error message:

error: More than one value for the key core.editor: mate

it means you've added multiple core.editor lines in your .gitconfig.

Use mate ~/.gitconfig to modify your .gitconfig and remove the extra lines, or if you don't mind unsetting all of them use:

git config --global --unset-all core.editor

Then use

git config --global --add core.editor "/usr/local/bin/mate -w"

then you can leave $EDITOR set to what it was previously set to.


If mate is not located in /usr/local/bin find where it is first by using type mate (in bash, not sure about other shells)


Since you want to use open as your $GIT_EDITOR you will need the following:

-W  Causes open to wait until the applications it opens (or that were already open) have exited.  Use with the -n flag to allow open to function as an appropriate app for the $EDITOR environment variable.

-n  Open a new instance of the application(s) even if one is already running.

This will work for that:

 git config --global --unset-all core.editor
 git config --global --add core.editor "open -W -n"

The following works for me:

git config --global core.editor "open -a 'Sublime Text 2' -nW"

Using Mac OSX 10.7.4 and Sublime Text 2 Build 2181

Note:

I have subl as an alias:

alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"