Git:打开文本编辑器时权限被拒绝

rya*_*nwc 3 git permissions macos bash

我正在尝试设置文本编辑器,该文本编辑器将在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
Run Code Online (Sandbox Code Playgroud)

但是,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.
Run Code Online (Sandbox Code Playgroud)

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

MyMac:aDir user$ open ~/Applications/TextEdit
Run Code Online (Sandbox Code Playgroud)

如何让Git让用户(此计算机上的唯一用户)打开TextEdit?

sda*_*yal 5

通过editor = open -W -n进入.gitconfig

假设Textedit是Mac上的默认编辑器,则需要open -W -n在.gitconfig中针对编辑器进行指定

在执行git commit时,该文件将在Textedit中自动打开

[user]
    name = My Name
    email = MyEmail@host.com
[core]
    autocrlf = input
    safecrlf = true
    editor = open -W -n
Run Code Online (Sandbox Code Playgroud)