如果我将我的 Git 设置为使用我的 GPG 密钥签名,它会失败。我已经尝试了GIT_TRACE,但它并没有真正给我更多信息:
$ GIT_TRACE=1 git commit
15:29:35.112157 git.c:344 trace: built-in: git 'commit'
15:29:35.115745 run-command.c:626 trace: run_command: 'code --wait' '/Users/b/VurbAgency/haarlem.github.io/.git/COMMIT_EDITMSG'
15:29:52.884006 run-command.c:626 trace: run_command: 'gpg' '--status-fd=2' '-bsau' 'SECRETKEYID'
error: gpg failed to sign the data
fatal: failed to write commit object
当我尝试运行'gpg' '--status-fd=2' '-bsau' 'SECRETKEYID'
时,它只是在说BEGIN_SIGNING H8
后挂起并且不再执行任何操作。
关于如何解决这个问题或研究途径的任何想法?
当我遇到同样的错误时,我偶然发现了这个,我已经在最新版本的 gpg (2.2.17(。对我来说,结果是多件事。
- 在提交之前,我必须运行
$ export GPG_TTY=$(tty)
.然后,这会提示显示密码提示。 - 如果我使用带有特殊字符的密码短语,它不起作用(提示说我在尝试使用时密码短语不正确(,所以我只能使用字母数字字符。
如果您这样做是为了在 GitHub 上获得经过验证的提交,请确保名称和电子邮件地址与您在 GitHub 上拥有的名称和电子邮件地址匹配。
如果您已经使用 Homebrew 安装了 gpg,并且还使用 GPGTools,则需要卸载 Homebrew 的 gpg。
# Uninstall gpg in homebrew so that it uses the gpg in GPGTools instead
$ brew uninstall gpg
# You might need to do some extra cleanup afterward as well:
$ rm -r /opt/homebrew/etc/gnupg
# Restart the gpg-agent so that it uses the correct one:
$ gpgconf --kill gpg-agent
在那之后,git 能够再次签署我的提交。
在我看到我的 GPG 是 2.2.5 版本并且最新的是 2.2.10 之后,我已经使用brew upgrade gpg
更新了 Mac 上的 GPG。
目前,这已经解决了这个问题。但是,我仍然不知道这个问题的原因是什么。
我遇到了同样的问题。在GnuPG配置文件~/.gnupg/gpg-agent.conf
中,pinentry-program
路径指向pinentry-mac
,而是缺失的。
运行brew install pinentry-mac
修复了它。
我遇到了类似的错误:BEGIN_SIGNING H10
.
在OSX上,为了修复它,我运行了gpgconf --kill gpg-agent