Git提交添加签名认证
安装gpg
brew install -v gpg
生成GPG key
git上的用户名和邮箱都要和生成的gpg一致
gpg --full-generate-key
查看GPG key
gpg --list-secret-keys --keyid-format=long
获取GPG 公钥
gpg --armor --export xxx
给Git配置GPG key
git config user.signingkey xxx
git config commit.gpgsign true
修改当前commit信息
git commit --amend '-S'
如果提交失败,信息为
error: gpg failed to sign the data
fatal: failed to write commit object
需要先下设置环境变量
export GPG_TTY=$(tty)