我刚开始使用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
当前回答
使用GIT_TRACE=1查看Git失败的地方,然后检查Git使用的所有自定义配置以及它们定义的地方,然后根据您的需要覆盖:
GIT_TRACE=1 git commit -S -m "this will tell you wich intern git command failed"
git config --list --show-scope --show-origin
对我来说,我有错误:gpg未能签署数据和致命:未能写入提交对象,因为Git默认使用smimesign,即使我取消设置gpg.x509。程序钥匙,smimesign找不到我的钥匙。
所以我必须显式地告诉Git使用gpg:
git config --local gpg.x509.program gpg
其他回答
我必须修好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>
然后按照上面给出的官方文档重新配置。 希望这能有所帮助。
你的git以某种方式配置为GPG签署每次提交。使用GPG签名不需要使用git提交或推送。它很可能会给出错误,因为您的gpg签名机制还没有配置。
如果您是git的新手,请尝试在一开始不使用GPG签名的情况下让它工作,然后在确实需要时添加签名。
你可以通过以下方法验证git是如何配置gpg的:
git config -l | grep gpg
它可以产生零或多行,包括:
commit.gpgsign=true
如果“提交。“Gpgsign”为真,则启用了GPG签名。禁用它:
git config --global --unset commit.gpgsign
然后尝试再次运行提交。现在它应该在没有gpg签名的情况下运行。在基本的git工作之后,您应该尝试将gpg签名重新添加到组合中。
可能你的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
经过大量搜索,我发现gpg密钥是我的情况下的问题。
如果您的gpg密钥正确,您可以尝试运行gpg——status-fd=2 -bsau <您的gpg密钥>。
要更新正确的密钥,请执行以下操作: 检查密钥使用:GPG——list-secret-keys——keyid-format=long
它应该有以下输出:
/Users/hubot/.gnupg/secring.gpg
------------------------------------
sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]
uid Hubot
ssb 4096R/42B317FD4BA89E7A 2016-03-10
然后更新密钥使用:
git config --global user.signingkey 3AA5C34371567BD2
现在再次检查提交,如果关键字是问题,它应该成功。您需要设置密码短语来更新密钥,您可以使用GitHub文档进行更新。
更多详情见:https://gist.github.com/paolocarrasco/18ca8fe6e63490ae1be23e84a7039374