设置 git ‘core.editor’ 时出现问题
我正在尝试在我的 Mac Os Snow Leopard 10.6.7 上设置 git,但我在执行此操作时犯了一些错误...
此时我有以下警告:
$ 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
如何我可以解决这个问题吗?而且,最重要的是,如何将 core.editor 设置为 TextEdit 并使其正常工作?
PS:我已经读过 这个问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最简单的方法是更改环境变量 EDITOR 以指向 mate。在
.bash_profile
中添加以下内容:并重新启动终端会话,或获取
.bash_profile
。至于您的错误消息:
这意味着您在 .gitconfig 中添加了多个 core.editor 行。
使用 mate
~/.gitconfig
修改您的.gitconfig
并删除多余的行,或者如果您不介意取消所有设置,请使用:然后使用
然后您可以离开
$EDITOR
设置为之前设置的内容。如果
mate
不在/usr/local/bin
中,首先使用type mate
查找它的位置(在 bash 中,不确定其他shell)由于您想使用
open
作为您的$GIT_EDITOR
您将需要以下内容:这将适用于:
The easiest way is to change the environment variable EDITOR to point to mate. In your
.bash_profile
add the following:and re-start your terminal session, or source the
.bash_profile
.As for your error message:
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:Then use
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 usingtype mate
(in bash, not sure about other shells)Since you want to use
open
as your$GIT_EDITOR
you will need the following:This will work for that:
以下对我有用:
使用 Mac OSX 10.7.4 和 Sublime Text 2 Build 2181
注意:
我将 subl 作为别名:
The following works for me:
Using Mac OSX 10.7.4 and Sublime Text 2 Build 2181
Note:
I have subl as an alias:
要使其适用于 win7,请打开 c:/users/username/ 文件夹中的 .gitconfig 文件,并在双引号外添加以下带有 --wait 选项的行。
希望对win7用户有帮助
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.
Hope its helpful to win7 users
对于它的价值,我是这样解决的:
1) 在终端中运行:
这会向
/usr/local/bin/
添加一个subl
别名,指向 Sublime Text 3 应用程序的二进制文件。现在在终端中运行subl
将启动 Sublime Text 3 应用程序。2) 在终端中运行:
这会将
editor = subl -n -w
添加到~/.gitconfig
文件的[core]
部分。现在在终端中运行git commit
将在新窗口 (-n
) 中启动 Sublime Text 3 应用程序 (subl
),并且命令行将等待 (-w
) 直到保存提交消息。Sublime Text 3 官方文档: http://www.sublimetext.com/docs/3/osx_command_line .html
For what it's worth, here's how I solved it:
1) Run in Terminal:
This adds a
subl
alias to/usr/local/bin/
pointing to Sublime Text 3 app’s binary file. Now runningsubl
in Terminal will launch Sublime Text 3 app.2) Run in Terminal:
This adds
editor = subl -n -w
to the[core]
section of the~/.gitconfig
file. Now runninggit 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