我刚开始使用git,我通过自制软件安装git和gpg。 由于某种原因,当我提交git时,我得到了这个错误 我看了很多关于这个话题的stackoverflow问题,但没有一个对我有用。 如何修复此错误以成功上传?

error: gpg failed to sign the data
fatal: failed to write commit object

当前回答

我必须修好gpg。编程到gpg的绝对路径:

git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"

我正在使用Windows cygwin。

其他回答

可能你的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

在我的例子中,当在一个小的tmux窗口上运行git提交时,这个错误发生了,这个窗口不能适合密码短语提示。

$ echo "test" | gpg --clearsign
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

test
gpg: signing failed: Screen or window too small
gpg: [stdin]: clear-sign failed: Screen or window too small

使用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

对我有用的故障安全措施:重启我的机器。

这种做法很严厉,而且最终可能无法阻止问题再次出现。但我也遇到了同样的问题,尝试了几乎所有答案的解决方案,但运气不佳。

在这里添加它,希望它能解除其他人在我的情况:)

为我解决这个问题的方法是确保密钥的名称与我的git用户名匹配。我猜邮件也要匹配。这可能与我在Mac上使用GPG钥匙串有关。不确定。

当我填写这个时,我以为我是在命名密钥,但我猜它是在询问我的名字(git用户名)。