设置 git ‘core.editor’ 时出现问题

发布于 2024-11-16 17:05:50 字数 555 浏览 8 评论 0原文

我正在尝试在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

最近可好 2024-11-23 17:05:50

最简单的方法是更改​​环境变量 EDITOR 以指向 mate。在 .bash_profile 中添加以下内容:

export EDITOR="/usr/local/bin/mate -w"

并重新启动终端会话,或获取 .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 中,不确定其他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.

这将适用于:

 git config --global --unset-all core.editor
 git config --global --add core.editor "open -W -n"

The easiest way is to change the environment variable EDITOR to point to mate. In your .bash_profile add the following:

export EDITOR="/usr/local/bin/mate -w"

and re-start your terminal session, or source the .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.

Use mate ~/.gitconfig to modify your .gitconfig and remove the extra lines, or if you don't mind unsetting all of them use:

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.


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)


Since you want to use open as your $GIT_EDITOR you will need the following:

-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"
删除→记忆 2024-11-23 17:05:50

以下对我有用:

git config --global core.editor "open -a 'Sublime Text 2' -nW"

使用 Mac OSX 10.7.4 和 Sublime Text 2 Build 2181

注意:

我将 subl 作为别名:

alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"

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

Note:

I have subl as an alias:

alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
陪你搞怪i 2024-11-23 17:05:50

要使其适用于 win7,请打开 c:/users/username/ 文件夹中的 .gitconfig 文件,并在双引号外添加以下带有 --wait 选项的行。

[core]
  editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --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.

[core]
  editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --wait

Hope its helpful to win7 users

最冷一天 2024-11-23 17:05:50

对于它的价值,我是这样解决的:

1) 在终端中运行:

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

这会向 /usr/local/bin/ 添加一个 subl 别名,指向 Sublime Text 3 应用程序的二进制文件。现在在终端中运行 subl 将启动 Sublime Text 3 应用程序。

2) 在终端中运行:

git config --global core.editor "subl -n -w"

这会将 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:

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.

2) Run in Terminal:

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.

Official Sublime Text 3 doc: http://www.sublimetext.com/docs/3/osx_command_line.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文