Git错误 - gpg未能签署数据 [英] Git error - gpg failed to sign data
问题描述
我刚开始使用git,我通过自制软件安装git和gpg。
出于某种原因,我得到这个错误,当我做 git commit
我看了很多关于这个话题的其他stackoverflow问题,他们都没有工作为了我。
如何修复此错误,以便我可以成功上传。
错误:gpg未能签署数据
致命:未能写入提交对象
对于故障排除,首先需要做两件事:
git config --global gpg.program gpg2
,确保git使用 gpg2
而不是 gpg
echotest| gpg2 --clearsign
,以确保 gpg2
本身正在运作
如果这一切看起来都是正确的,接下来要试一下:
brew install pinentry
确保您有一个安装好的工具用于密码输入
如果在安装后重新尝试 git commit
,仍然得到未能签署数据
错误:
$
gpgconf --kill gpg-agent
来终止任何可能被挂起的正在运行的代理程序
如果没有安装 gpgconf
或没有 - -kill
选项,您可以 试试这个:
-
cp〜/ .gnupg〜/ .gnupg-GOOD
保存你的〜/ .gnupg
的副本以在需要时恢复到 li>
-
brew install gnupg21
安装GnuPG 2.1
保存的副本的原因〜/ .gnupg
dir是GnuPG 2.1可能创建/更改一些不与GnuPG 2.0及更早版本向后兼容的关键数据,所以 if 你想要稍后再回来,你可以做 mv〜/ .gnupg〜/ .gnupg21&& mv〜/ .gnupg-GOOD〜/ .gnupg
。
否则有一些基本的步骤来检查你是否有一个可用的GnuPG环境:
gpg2 -K --keyid-格式SHORT
,以检查您是否至少有一个密钥对
如果输出显示给您没有密钥供GnuPG使用,那么你需要创建一个:
- 运行
gpg2 --gen- key
,让GnuPG引导您完成创建密钥对的步骤
如果您收到一条错误消息,提示设备不适用ioctl,请执行以下操作:
导出GPG_TTY = $(tty)
和/或将其添加到〜/ .bashrc
或〜/ .bash_profile
I just started using git and I install git and gpg via homebrew.
For some reason, I get this error when i do git commit
I looked at so many other stackoverflow questions regarding this topic and none of them worked for me.
How can I fix this error so that I can upload successfully.
error: gpg failed to sign the data
fatal: failed to write commit object
For troubleshooting, two things to first try:
- run
git config --global gpg.program gpg2
, to make sure git usesgpg2
and notgpg
- run
echo "test" | gpg2 --clearsign
, to make suregpg2
itself is working
If that all looks all right, one next thing to try:
- run
brew install pinentry
to ensure you have a good tool installed for passphrase entry
If after that install and you re-try git commit
and still get the "failed to sign the data
" error:
- run
gpgconf --kill gpg-agent
to kill any running agent that might be hung
If that says gpgconf
isn’t installed or doesn’t have a --kill
option, you might try this:
cp ~/.gnupg ~/.gnupg-GOOD
to save a copy of your~/.gnupg
to revert to later if neededbrew install gnupg21
to install GnuPG 2.1
The reason for saving a copy of your ~/.gnupg
dir is that GnuPG 2.1 potentially creates/changes some key data in way that isn’t backward-compatible with GnuPG 2.0 and earlier, so if you want to go back later, you can do mv ~/.gnupg ~/.gnupg21 && mv ~/.gnupg-GOOD ~/.gnupg
.
Otherwise there are some basic steps to run to check you’ve got a working GnuPG environment:
- run
gpg2 -K --keyid-format SHORT
, to check that you have at least one key pair
If the output of that shows you have no secret key for GnuPG to use, then you need to create one:
- run
gpg2 --gen-key
, to have GnuPG walk you through the steps for creating a key pair
If you get an error message saying "Inappropriate ioctl for device", do this:
- run
export GPG_TTY=$(tty)
and/or add that to your~/.bashrc
or˜/.bash_profile
这篇关于Git错误 - gpg未能签署数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!