我刚开始使用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
当前回答
解决方案:
Issue: Disabled loopback pinentry mode
要解决这个问题,你需要在~/.gnupg/gpg.conf中启用环回pinentry模式:
cat <<'EOF' >> ~/.gnupg/gpg.conf
use-agent
pinentry-mode loopback
EOF
还有~/.gnupg/gpg-agent.conf(如果文件不存在就创建文件):
cat <<'EOF' >> ~/.gnupg/gpg-agent.conf
allow-loopback-pinentry
EOF
然后使用echo RELOADAGENT | gpg-connect-agent重新启动代理,您应该可以运行了!
源
其他回答
在我的例子中,当在一个小的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以某种方式配置为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
参考@sideshowbarker和@Xavier Ho解决方案,我通过以下步骤解决了我的问题。
假设gpg2通过brew安装,
git config --global gpg.program gpg2
brew install pinentry
gpgconf --kill gpg-agent
gpg2 -K --keyid-format SHORT
// no key found then generate new one
gpg2 --gen-key
gpg2 -K --keyid-format SHORT
... - dpg gnupg - pubring。
sec rsa2048/0A61C6FC 2017-06-29 [SC][有效期:2019-06-29]
git config --global user.signingkey 0A61C6FC
经同事提醒,需要追加
export GPG_TTY=$(tty)
~ /。ZSHRC如果使用zsh,否则追加到~/.bash_profile
For macOS,
gpg2在brew中与GPG结合,因此GPG命令指向gpg2
brew install gpg2
酿造信息GPG
Gnupg:稳定2.2.6(瓶装)
git config --global gpg.program gpg
gpg -K --keyid-format SHORT
还有pinentry-mac用于密码输入
brew install pinentry-mac
vim ~/.gnupg/gpg-agent.conf
添加一行
pinentry-program /usr/local/bin/pinentry-mac
经同事提醒,需要追加
export GPG_TTY=$(tty)
~ /。ZSHRC如果使用zsh,否则追加到~/.bash_profile
如果你之前已经安装了pinentry和gpg,它突然就不工作了:
检查你的gpg是否正常工作:
echo "test" | gpg --clearsign
如果它说gpg: signing failed: No pinentry, 只需重新启动GPG守护进程客户端,它会不时卡住:
gpgconf --kill gpg-agent
现在它应该工作了:
echo "test" | gpg --clearsign