Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
960 views
in Technique[技术] by (71.8m points)

macos - Trouble on setting the git 'core.editor'

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...