我刚开始使用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以某种方式配置为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签名重新添加到组合中。
其他回答
如果你之前已经安装了pinentry和gpg,它突然就不工作了:
检查你的gpg是否正常工作:
echo "test" | gpg --clearsign
如果它说gpg: signing failed: No pinentry, 只需重新启动GPG守护进程客户端,它会不时卡住:
gpgconf --kill gpg-agent
现在它应该工作了:
echo "test" | gpg --clearsign
为我解决这个问题的方法是确保密钥的名称与我的git用户名匹配。我猜邮件也要匹配。这可能与我在Mac上使用GPG钥匙串有关。不确定。
当我填写这个时,我以为我是在命名密钥,但我猜它是在询问我的名字(git用户名)。
可能你的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
如果它曾经工作,只是声明失败,杀死代理,再试一次:
gpgconf --kill gpg-agent
检查代理是否再次启动:
echo "test" | gpg --clearsign
如果你使用的是windows powershell(5.1+),我想这个命令可以工作。
使用此命令获取GPG程序路径。
(Get-Command gpg).Path
在获取路径之后,复制路径。 使用这个命令
git config gpg.program <your path>
试着做出承诺。 编码快乐! !