Git:打开文本编辑器时出现权限被拒绝的问题

3

我试图设置Git在需要我输入文本时(例如提交信息)打开的文本编辑器。

我使用Mac OSX 10.9.5并且使用bash。我已将默认编辑器配置为TextEdit,我的.gitconfig文件如下所示:

[user]
    name = My Name
    email = MyEmail@host.com
[core]
    autocrlf = input
    safecrlf = true
    editor = /Applications/TextEdit.app

然而,Git不允许我打开TextEdit:
MyMac:aDir user$ git commit
fatal: cannot exec '/Applications/TextEdit.app': Permission denied
error: unable to start editor '/Applications/TextEdit.app'
Please supply the message using either -m or -F option.

我曾试图将TextEdit移动到我的用户目录下,但我只能移动一个别名(我认为它只是指向原始TextEdit位置的指针)。因此,我得到了相同的结果。但这只是Git的问题,因为这个可以起作用:

MyMac:aDir user$ open ~/Applications/TextEdit

我该如何让Git允许用户(这台电脑上唯一的用户)打开TextEdit?
1个回答

7

通过在你的 .gitconfig 文件中添加 editor = open -W -n

假设 Textedit 是你的默认编辑器,你需要在 .gitconfig 中指定 open -W -n 作为编辑器。

当进行 git commit 操作时,文件将自动在 Textedit 中打开。

[user]
    name = My Name
    email = MyEmail@host.com
[core]
    autocrlf = input
    safecrlf = true
    editor = open -W -n

没有起作用,除非我理解错了。 MyMac:aDir用户$ git commit “open -W -n”:“找不到命令open” 错误:编辑器'“open -W -n”'出现问题。 请使用“-m”或“-F”选项提供消息。 - ryanwc
你需要使用上述信息编辑你的.gitconfig文件(open -W -n)。在提交时使用git commit命令。 - sdayal
是的,.gitcommit文件完全按照您指定的方式,但它不起作用。它会出现我在上面评论中显示的错误。 - ryanwc
对于其他读者,这个答案不起作用,我仍在寻找。 - ryanwc
1
好的,我明白了。您需要从最后一行中删除引号,这样它就只是editor = open -W -n谢谢。 - ryanwc

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接