目前,我在运行git 2.15.0.windows.1,gpg 2.2.1和gpg-agent 2.2.1的Windows上。我正在尝试通过pinentry / gpg-agent与git签署提交,但是,当通过git签署提交时,pinentry永远不会出现,并且git会引发错误。我仍然能够通过gpg签署提交,但不能通过git签名。
> git commit -a -S -m "Signed Commit"
gpg: gpg-agent is not available in this session
gpg: Sorry, no terminal at all requested - can't get input
error: gpg failed to sign the data
fatal: failed to write commit object
我仍然可以在没有git的情况下通过gpg进行签名:
我的gpg.conf:
keyserver hkp://keys.gnupg.net
no-tty
use-agent
当我删除最后两行时,gpg仍然会弹出pinentry,然后git可以再次签署提交,但是它将仅通过命令行而不是pinentry接受密码短语输入。
如何解决原始错误并使签名提交弹出pinentry?
我能够通过设置正确的git config选项来修复它。
首先,通过运行获取正确的签名,gpg --list-signatures
然后查找标记为sig
或的签名ID。sig 3
sig 3 54ABFD17372D7B88 ...
然后将git config设置为user.signingkey
:
git config --global user.signingkey 54ABFD17372D7B88
最后,设置gpg.program
为gpg.exe
二进制文件的位置。
git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"
现在,当您使用-S
或提交时--gpg-sign
,您应该会看到pinentry框。
如果您希望它与大多数GUI程序一起使用,例如VS Code,GitHub Desktop和基于IDEA的产品(PyCharm,Android Studio,PHPStorm等),则应设置commit.gpgsign
为true:
git config --global commit.gpgsign true
这将签署每个提交。如果您不想签署特定的提交,请--no-gpg-sign
在提交时使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句