我参考了几篇关于Git 2.10发行说明中的漂亮属性的文章。将git升级到2.10.0,并对全局的.gitconfig进行了更改,结果如下-

[filter "lfs"]
    clean = git-lfs clean %f
    smudge = git-lfs smudge %f
    required = true
[user]
    name = xyz
    email = abc.def@gmail.com
    signingkey = AAAAAAA
[core]
    excludesfile = /Users/xyz/.gitignore_global
    editor = 'subl' --wait
[difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path = 
[mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
[alias]
    lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
[color "diff"]
    old = red strike
    new = green italic

但是现在我尝试使用

git commit -a -S -m "message"

我看到下面的错误-

你需要一个密码来解锁秘钥 用户:“XYZ(数字签名)” 2048-bit RSA key, ID AAAAAAAA, created 2016-07-01 错误:GPG数据签名失败致命:写提交失败 对象

注意-我仍然可以使用git commit -a -m "message"来提交更改

有办法克服同样的问题吗?或者在gpg配置中需要做任何改变以适应git的升级?


更新1

还寻求进一步的有用性,以下是是否有一种方法在Git中使用GPG密钥“自动签名”提交?我已经配置了密钥使用

git config --global user.signingkey ED5CDE14(with my key) 
git config --global commit.gpgsign true

很明显得到了相同的错误。


当前回答

按照下面的url设置签名提交 https://help.github.com/en/articles/telling-git-about-your-signing-key

如果还在 GPG签署数据失败致命: 日志含义写提交对象失败

这不是git的问题,而是GPG的问题 遵循以下步骤

gpg——版本 回显"test" | GPG—clearsign

如果显示:

gpg: signing failed: Inappropriate ioctl for device
gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device

然后使用export GPG_TTY=$(tty) 然后再次尝试echo“test”| GPG—clearsign 得到PGP签名。 Git config -l | grep GPG

gpg.program=gpg
commit.gpgsign=true

应用git commit -m "commitMsz"

其他回答

我也遇到了同样的问题。我很高兴地报告,问题不在于git 2.10.0,而在于gnupg 1.4.21。

暂时将gnupg降级到1.4.20为我解决了这个问题。

如果你正在使用自制程序,并且像我一样升级了你的包,你可能只需要运行brew开关gnupg 1.4.20来恢复。

如果你不想处理brew来安装gpg,这似乎时不时会遇到问题,只需从gpg tools下载gpg工具。

在执行向导时,单击customize install并取消选择邮件插件(除非您想使用它)。这些工具似乎没有遇到任何问题,而且它会在你第一次签署提交后记住你的密码。不需要额外的配置,除了告诉git使用哪个键。

至少这是我的经验。

如果你的问题是Visual Studio Code不允许提交,但你已经设置了你的GPG签名,用bash的一行答案是:

git config --global gpg.program `which gpg2`

如果你在PATH中有gpg,但没有gpg2,那么就用它来代替。

使用以下命令检查gpg是否启用

git config -l | grep gpg

如果它返回true,运行以下命令禁用它

git config --global --unset commit.gpgsign

成功运行上述命令后,应该可以运行git commit命令。

我的解决方案是:

首先,我试图了解为什么这是行不通的细节。在终端上按cmd命令尝试

   $ echo "Hello" > test.txt
   $ gpg --sign --default-key <your-email-id> test.txt

观察到详细信息错误:gpg: signing failed: No pinentry

gpg-agent[59045]: can't connect to the PIN entry module '/usr/local/bin/pinentry': IPC connect call failed .日志含义 gpg-agent[59045]: failed to unprotect the secret key: No pinentry .日志含义

从终端我点击下面的cmd:

    cat ~/.gnupg/gpg-agent.conf

检查以下陈述是否存在。如果gpg-agent.conf中没有,需要添加

pinentry-program /usr/local/MacGPG2/libexec/pinentry-mac.app /内容/ MacOS / pinentry-mac

添加pinentry路径后,运行

    $ gpgconf --kill gpg-agent
    $ gpg --sign --default-key <your-email-id> test.txt

查看输出:

 gpg: using <your-email-id> as default secret key for signing