git - 设置 git 'core.editor' 时遇到问题

标签 git macos editor warnings 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

我该如何解决?而且,最主要的是,如何将 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/

相关文章:

git - 所以更改了 Git 的默认编辑器,现在我如何从 Git bash 调用它?

editor - 通过单击装订线空间在 Ace 编辑器中添加/删除断点

macos - Mac OS X 上的焦点跟随鼠标(加上自动抬起)

macos - 将 CMake 移植到 OS X Yosemite

python代码发出蜂鸣声

git - Ediff 作为 git difftool

unity3d - 如何在编辑器窗口中显示和修改数组?

ruby-on-rails - 在 Capistrano 中部署 Git 子目录

bash - 仅当“git diff”输出某些内容时,如何运行另一个 git 命令?

git - 在 Git 中,有没有办法将文件标记为 "pure"?