我刚开始使用git,我通过自制软件安装git和gpg。 由于某种原因,当我提交git时,我得到了这个错误 我看了很多关于这个话题的stackoverflow问题,但没有一个对我有用。 如何修复此错误以成功上传?
error: gpg failed to sign the data
fatal: failed to write commit object
我刚开始使用git,我通过自制软件安装git和gpg。 由于某种原因,当我提交git时,我得到了这个错误 我看了很多关于这个话题的stackoverflow问题,但没有一个对我有用。 如何修复此错误以成功上传?
error: gpg failed to sign the data
fatal: failed to write commit object
当前回答
我刚刚在VSCode更新时遇到了这个问题。我认为GPG代理挂起了,因为该命令在出错之前运行了几秒钟。运行gpgconf——kill gpg-agent重置并为我修复了它。
其他回答
我已经做了一个git密钥,有3个单独的密钥用于认证/签名/加密&密钥在未来显示过期(在正常工作几天后):
pub rsa4096/4CD1E9DA 2017-04-26 [C] [expired: 2017-04-28]
Key fingerprint = 4670 59C1 7592 08B8 7FA5 313B 2A42 B6A6 4CD1 E9DA
uid [ expired] Stuart Cardall (GIT Development Keys) <xxxxxx>
sub rsa4096/5195E715 2017-04-26 [E] [expired: 2019-04-26]
sub rsa4096/DB74C297 2017-04-26 [S] [expired: 2019-04-26]
sub rsa2048/A3913A3C 2017-04-28 [] [expired: never ]
在不添加单独子键的情况下创建一个新键来解决问题。
我必须修好gpg。编程到gpg的绝对路径:
git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"
我正在使用Windows cygwin。
在我的例子中,我混合了提交签名文档中给出的gpg配置和smimesign配置:https://help.github.com/en/github/authenticating-to-github/telling-git-about-your-signing-key
在工作了几个小时之后,我发现纠正它的最好方法是取消与gpg相关的所有内容,并重新配置gpg。
正如在@Jason Thrasher的回答中提到的,使用以下方法找到所有与gpg相关的git配置:
git config -l | grep gpg
然后取消所有的golable以及本地使用:
git config --global --unset <config_name>
git config --local --unset <config_name>
然后按照上面给出的官方文档重新配置。 希望这能有所帮助。
什么是gpg: GNU Privacy Guard
用法:
GPG是确保双方安全通信的一种极好的方法。它允许敏感信息在不安全的网络上轻松共享。
简单的解决方案:
步骤1:检查密钥是否过期请做
gpg -K——keyid-format SHORT
步骤2:如果它没有过期
Git配置——global user.signingkey
可能你的Git配置设置为gpgsign = true。如果你不想指定你的提交,试着把它设置为false。转到存储库文件夹并更改该文件
纳米git -配置。
从这个……
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@bitbucket.org:yourrepo/project.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
signingkey = <GPG-KEY>
[commit]
gpgsign = true
这……
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@bitbucket.org:yourrepo/project.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
signingkey = <GPG-KEY>
[commit]
gpgsign = false