【发布时间】:2017-11-14 07:22:37
【问题描述】:
我正在学习 Git 的基础知识,但在尝试使用 Sublime 2 作为提交消息的默认文本编辑器时遇到了问题。
我使用的是 Mac 和 Sublime 文本编辑器(版本 2.0.2,Build 2221)
按照help.github 上的说明,我使用了以下行:
git config --global core.editor "subl -n -w"
但是,当我尝试 git commit 命令时,我收到以下消息:
subl -n -w: subl: command not found
error: There was a problem with the editor 'subl -n -w'.
Please supply the message using either -m or -F option.
我知道subl 和subl -n -w 可以工作,因为我已经单独尝试过它们,它们会启动编辑器。所以问题一定是从git commit命令打开编辑器的时候。
【问题讨论】:
-
在您的 Mac 上,
subl二进制文件在哪里?也就是说,which subl说什么?接下来,检查当 git 运行子命令时您的$PATH设置为什么(例如,暂时将core.editor设置为env并运行git config -e或其他东西,以便您可以检查PATH设置)。可能您需要摆弄您的.profile或.cshrc,因为它们可能会将带有subl的目录从您的路径中移除。 -
感谢您的帮助。抱歉,如果这不完全符合您的要求,但我是命令行新手。 i)
which subl命令没有返回任何内容。 ii)git config e返回以下错误:env: /Users/My_Name/File_Name/.git/config: Permission denied error: There was a problem with the editor 'env'. -
有人在另一个论坛上发布了解决方案。命令是
git config --global core.editor "'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' -n -w"。这是否表明错误是符号链接?如果是这样,有人可以发布建立符号链接的正确方法,以便命令git config --global core.editor "subl -n -w"可以工作 -
完整路径有效仍然意味着您的
$PATH是错误的,因为通常您希望直接在您的$PATH上运行您打算运行的东西(例如.../bin/subl)。我不确定您的意思是什么符号链接,您的帖子和链接的 help.github.com 中都没有。
标签: git version-control sublimetext2 git-commit