设置git'core.editor'的麻烦

use*_*052 9 git macos warnings editor osx-snow-leopard

我试图在我的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
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?而且,大多数情况下,我如何设置core.editorTextEdit并使其工作?

PS:我已经读过这个问题.

X-I*_*nce 25

最简单的方法是将环境变量EDITOR更改为指向配合.在您.bash_profile添加以下内容:

export EDITOR="/usr/local/bin/mate -w"
Run Code Online (Sandbox Code Playgroud)

并重新开始您的终端会话,或来源.bash_profile.

至于你的错误信息:

error: More than one value for the key core.editor: mate
Run Code Online (Sandbox Code Playgroud)

这意味着你在.gitconfig中添加了多个core.editor行.

使用配合~/.gitconfig来修改.gitconfig和删除多余的行,或者如果你不介意取消所有这些,请使用:

git config --global --unset-all core.editor
Run Code Online (Sandbox Code Playgroud)

然后用

git config --global --add core.editor "/usr/local/bin/mate -w"
Run Code Online (Sandbox Code Playgroud)

然后你可以将$EDITORset设置为之前设置的值.


如果mate不是位于/usr/local/bin找到它首先是通过使用type mate(在bash,不知道其他shell)


由于您想要使用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.
Run Code Online (Sandbox Code Playgroud)

这将适用于此:

 git config --global --unset-all core.editor
 git config --global --add core.editor "open -W -n"
Run Code Online (Sandbox Code Playgroud)