Trouble on setting the git 'core.editor'

user502052 picture user502052 · Jun 22, 2011 · Viewed 16.6k times · Source

I am trying to set git on my Mac Os Snow Leopard 10.6.7 but I made some errors on doing that...

At this time I have the following warning:

$ git config --global core.editor
EDITOR=/usr/bin/vim
error: More than one value for the key core.editor: mate
$ git config --global core.editor open
warning: core.editor has multiple values

How can I solve that? And, mostly, how can I set the core.editor to TextEdit and make it works?

P.S.: I already read this question.

Answer

X-Istence picture X-Istence · Jun 22, 2011

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"