error: gpg failed to sign the data 的一个解决办法

问题:使用gpg加密时不能commit

error: gpg failed to sign the data
fatal: failed to write commit object

原文链接:https://www.codenong.com/41502146/

以下是原文

  • brew uninstall gpg
  • brew install gpg2
  • brew install pinentry-mac(如果需要)
  • gpg --full-generate-key使用算法创建密钥。
  • 通过执行以下命令获取生成的密钥:gpg --list-keys
  • 在此处设置密钥git config --global user.signingkey <Key from your list>
  • git config --global gpg.program /usr/local/bin/gpg
  • git config --global commit.gpgsign true
  • 如果要将密钥导出到GitHub,请:gpg --armor --export <key>
    并将此密钥通过GPG密钥添加到GitHub:https://github.com/settings/keys(包括START和END行)

如果问题仍然存在:

test -r ~/.bash_profile && echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile

echo 'export GPG_TTY=$(tty)' >> ~/.profile

原文地址:https://www.cnblogs.com/julymaple/p/14657149.html