“No secret key” error when signing git commit on Windows

喜欢而已 提交于 2020-12-06 07:27:31

问题


I'm getting this error when trying to sign a commit:

git commit -S -m "test"
gpg: skipped "EF617ACA9EC3XXXX": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object

This is the output of gpg --list-secret-keys --keyid-format LONG

The key is present there

sec   rsa4096/EF617ACA9EC3XXXX 2020-05-17 [SC] [expires: 2022-05-17]
      AD68154000A712DCD161D826EF617ACA9EC3XXXX
uid                 [ultimate] name <email@gmail.com>

And this is git config with the same key

user.signingkey=EF617ACA9EC3XXXX
user.email=email@gmail.com

Any idea what's wrong?


回答1:


Check first the git config gpg.program to see if this is gpg or gpg2 (as in here).

And type where gpg nd where gpg2 to check which path is considered for the GPG program.

I suggested to set gpg.program to gpg2, and copy your gpg.exe (assuming its version is a 2.x) to gpg2.exe

That should force Git/GPG to act as gpg2.




回答2:


In case anyone is a dufus like me I was getting this error because I had the gitkey wrong while directly editing the file via: git config --global -e or code ~/.gitconfig or whatever flavor of editor you enjoy.

  • singingkey 🎶🔑 instead of
  • signingkey 🤦‍♂️


来源:https://stackoverflow.com/questions/61849061/no-secret-key-error-when-signing-git-commit-on-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!