我正在尝试在我的 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 并使其正常工作?
P.S.:我已经阅读了 this question .
最佳答案
最简单的方法是将环境变量 EDITOR 更改为指向 mate。在您的 .bash_profile
中添加以下内容:
export EDITOR="/usr/local/bin/mate -w"
并重新启动您的终端 session ,或获取 .bash_profile
。
至于你的错误信息:
error: More than one value for the key core.editor: mate
这意味着您已经在 .gitconfig 中添加了多个 core.editor 行。
使用 mate ~/.gitconfig
修改你的 .gitconfig
并删除多余的行,或者如果你不介意取消所有设置,请使用:
git config --global --unset-all core.editor
然后使用
git config --global --add core.editor "/usr/local/bin/mate -w"
然后您可以将 $EDITOR
设置为之前设置的值。
如果 mate
不在 /usr/local/bin
中,首先使用 type mate
找到它的位置(在 bash 中,不是确定其他外壳)
因为你想使用 open
作为你的 $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.
这将适用于:
git config --global --unset-all core.editor
git config --global --add core.editor "open -W -n"
关于git - 设置 git 'core.editor' 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6435246/