我从brew安装了GPG.
brew install gpg
Run Code Online (Sandbox Code Playgroud)
这是gnupg2-2.0.30_2.
当我提交时,我收到一条错误消息:
You need a passphrase to unlock the secret key for
user: "Max Mustermann (mycomment) <mm@test.de>"
2048-bit RSA key, ID 1111AAAA, created 2017-01-05
error: gpg failed to sign the data
fatal: failed to write commit object
Run Code Online (Sandbox Code Playgroud)
我使用了命令:
gpg --list-secret-keys | grep ^sec
Run Code Online (Sandbox Code Playgroud)
它让我回来:
sec 2048R/1111AAAA 2017-01-05
Run Code Online (Sandbox Code Playgroud)
然后我用这个命令:
git config --global user.signingkey 1111AAAA
Run Code Online (Sandbox Code Playgroud)
commit给了我相同的错误消息.
我怎么解决这个问题?
sid*_*ker 30
如果你没有得到密码提示(你没有提到你是否......),解决方案可能只是安装一个程序来促进这一点.最常见的是松树.
brew install pinentry-mac
Run Code Online (Sandbox Code Playgroud)
所以安装并重新尝试可能会让事情变得有效.但如果没有,另一件事就是确保git它使用/找到合适的GPG程序.这些天你真的应该使用gpg2,所以如果你还没有安装,请执行:
brew install gnupg2
Run Code Online (Sandbox Code Playgroud)
然后,告诉git那是GPG计划想要你,这个:
git config --global gpg.program gpg2
Run Code Online (Sandbox Code Playgroud)
此时,再次尝试提交,事情可能会奏效.
但如果没有,那试试这个:
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
Run Code Online (Sandbox Code Playgroud)
......然后再试一次.
注意:根据下面的一些注释,为了使此更改生效,您显然可能需要在进行更改后重新启动.
对于在MacOS计算机上面临此问题的任何人,请尝试以下操作:
brew uninstall gpg brew install gpg2brew install pinentry-mac (如果需要的话)gpg --full-generate-key 通过使用算法创建密钥。gpg --list-keysgit config --global user.signingkey <Key from your list> git config --global gpg.program /usr/local/bin/gpggit config --global commit.gpgsign truegpg --armor --export <key>
and add this key to GitHub at GPG keys: https://github.com/settings/keys (with START and END line included)If the issue still exists:
test -r ~/.bash_profile && echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile
echo 'export GPG_TTY=$(tty)' >> ~/.profile
If the issue still exists:
Install https://gpgtools.org and sign the key that you used by pressing Sign from the menu bar: Key->Sign
If the issue still exists:
Go to: ??your global .gitconfig file which in my case is at: ??/Users/gent/.gitconfig
And modify the .gitconfig file (please make sure Email and Name are the same with the one that you have created while generating the Key):
[user]
email = gent@youremail.com
name = Gent
signingkey = <YOURKEY>
[gpg]
program = /usr/local/bin/gpg
[commit]
gpsign = true
gpgsign = true
[filter "lfs"]
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
[credential]
helper = osxkeychainRun Code Online (Sandbox Code Playgroud)
p.s I took this answer from my previous answer here: gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]
我有同样的错误信息,发现我的密钥已过期。因此,通过以下方式检查您的密钥过期可能是个好主意:
gpg --list-keys
如果您的密钥也已过期,您可以通过以下方式调整过期日期:
gpg --edit-key <YOUR_KEY>
进而:
gpg> expire
...enter the new expiration date...
gpg> save
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10663 次 |
| 最近记录: |