设置 git 'core.editor' 时遇到问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6435246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trouble on setting the git 'core.editor'
提问by user502052
I am trying to set git on my Mac Os Snow Leopard 10.6.7but I made some errors on doing that...
我试图在我的Mac Os Snow Leopard 10.6.7上设置 git但我在这样做时犯了一些错误......
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?
我该如何解决?而且,最重要的是,我如何将 设置core.editor
为 TextEdit 并使其工作?
P.S.: I already read this question.
PS:我已经阅读了这个问题。
回答by X-Istence
The easiest way is to change the environment variable EDITOR to point to mate. In your .bash_profile
add the following:
最简单的方法是将环境变量 EDITOR 更改为指向 mate。在您.bash_profile
添加以下内容:
export EDITOR="/usr/local/bin/mate -w"
and re-start your terminal session, or source the .bash_profile
.
并重新启动您的终端会话,或获取.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.
这意味着您在 .gitconfig 中添加了多个 core.editor 行。
Use mate ~/.gitconfig
to modify your .gitconfig
and remove the extra lines, or if you don't mind unsetting all of them use:
使用 mate~/.gitconfig
修改您的.gitconfig
并删除多余的行,或者如果您不介意取消所有这些行,请使用:
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.
然后您可以将$EDITOR
设置保留为之前设置的设置。
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)
如果mate
不是/usr/local/bin
通过使用找到它的第一个位置type mate
(在bash中,不确定其他shell)
Since you want to use open
as your $GIT_EDITOR
you will need the following:
由于您想使用open
as your,$GIT_EDITOR
您将需要以下内容:
-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"
回答by kenglxn
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
使用 Mac OSX 10.7.4 和 Sublime Text 2 Build 2181
Note:
笔记:
I have subl as an alias:
我有 subl 作为别名:
alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
回答by 2540625
For what it's worth, here's how I solved it:
对于它的价值,这是我解决它的方法:
1) Run in Terminal:
1)在终端运行:
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.
这会添加一个subl
别名以/usr/local/bin/
指向 Sublime Text 3 应用程序的二进制文件。现在subl
在终端中运行将启动 Sublime Text 3 应用程序。
2) Run in Terminal:
2)在终端运行:
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.
这将添加editor = subl -n -w
到文件的[core]
部分~/.gitconfig
。现在git commit
在终端中运行将subl
在新窗口 ( -n
) 中启动 Sublime Text 3 应用程序 ( ),命令行将等待 ( -w
) 直到提交消息被保存。
Official Sublime Text 3 doc: http://www.sublimetext.com/docs/3/osx_command_line.html
官方 Sublime Text 3 文档:http: //www.sublimetext.com/docs/3/osx_command_line.html
回答by Anmol Saraf
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.
要使其适用于 win7,请打开 c:/users/username/ 文件夹中的 .gitconfig 文件,并在双引号外添加以下带有 --wait 选项的行。
[core]
editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --wait
Hope its helpful to win7 users
希望对win7用户有所帮助