GPG failed to write commit object

Got an error:

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

It took me more than two hours to narrow down the cause of the error:

These does not work too:

MacBook-Air:~ jack$ gpg2 --list-secret-keys
gpg: can't connect to the agent: IPC connect call failed
MacBook-Air:~ jack$ gpg-agent --daemon
gpg-agent[1499]: /Users/jack/.gnupg/gpg-agent.conf:2: invalid option

Error is caused by wrong configuration in gpg-agent.conf:

$ cat ~/.gnupg/gpg-agent.conf

For some reasons the second line was added to the configuration:

pinentry-program /usr/local/bin/pinentry-mac 
/usr/local/bin/pinentry-mac

That should just configured with this:

pinentry-program /usr/local/bin/pinentry-mac

After correcting the configuration, gpg-agent is now working:

MacBook-Air:~ jack$ gpg-agent -v --daemon
gpg-agent[2012]: listening on socket '/Users/jack/.gnupg/S.gpg-agent'
gpg-agent[2012]: listening on socket '/Users/jack/.gnupg/S.gpg-agent.extra'
gpg-agent[2012]: listening on socket '/Users/jack/.gnupg/S.gpg-agent.browser'
gpg-agent[2012]: listening on socket '/Users/jack/.gnupg/S.gpg-agent.ssh'
gpg-agent[2013]: gpg-agent (GnuPG) 2.1.21 started

And so is gpg2:

MacBook-Air:~ jack$ gpg2 --list-secret-keys
gpg-agent[2013]: handler 0x70000e9d4000 for fd 7 started
/Users/jack/.gnupg/pubring.gpg
------------------------------
sec   rsa2048 2016-12-12 [SC]

With that, committing with gpg signing shall work, must configure gpg to use gpg2 if it is not yet configured to gpg2:

MacBook-Air:~ jack$ git config --global gpg.program gpg2

Happy Coding!

稿源:anicehumble (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合技术 » GPG failed to write commit object

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录