开发者

Trouble on setting the git 'core.editor'

开发者 https://www.devze.com 2023-03-14 08:56 出处:网络
I am trying to set git on my Mac Os开发者_StackOverflow Snow Leopard 10.6.7 but I made some errors on doing that...

I am trying to set git on my Mac Os开发者_StackOverflow 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.


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"


For what it's worth, here's how I solved it:

1) Run in Terminal:

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

This adds a subl alias to /usr/local/bin/ pointing to Sublime Text 3 app’s binary file. Now running subl in Terminal will launch Sublime Text 3 app.

2) Run in Terminal:

git config --global core.editor "subl -n -w"

This adds editor = subl -n -w to the [core] section of the ~/.gitconfig file. Now running git commit in Terminal will launch Sublime Text 3 app (subl) in a new window (-n), and the command line will wait (-w) until the commit message is saved.

Official Sublime Text 3 doc: http://www.sublimetext.com/docs/3/osx_command_line.html


To get this working for win7, open the .gitconfig file in c:/users/username/ folder and add the following line with --wait option outside the double quotes.

[core]
  editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --wait

Hope its helpful to win7 users

0

精彩评论

暂无评论...
验证码 换一张
取 消