Git提交未经验证但应该被验证

5
我的提交目前显示为“未验证”,但应该设置为“已验证”。
我按照此指南创建了我的GPG密钥,当我运行gpg --list-secret-keys --keyid-format LONG时,我得到以下结果:
sec   rsa4096/SOME_KEY 2019-10-24 [SC]
      SOME_OTHER_LONGER_KEY
uid                 [ultimate] Ryan Wood <myemail@address.com>
ssb   rsa4096/SOME_OTHER_KEY 2019-10-24 [E]

我执行了命令gpg --armor --export SOME_KEY以生成公钥,并按照这里的说明将其放在GitHub上。此外,我根据这篇指南设置了git config --global commit.gpgsign true,并在最后一次提交时提示输入密码,我正确输入了密码。我还验证了我提供给GPG的电子邮件和我在GitHub上列出的电子邮件是相同的。最后,我根据这个问题中提供的答案设置了我的签名密钥,即git config --global user.signingkey SOME_KEY。然而,我的提交未经验证。
请问我是否需要执行其他操作或者该过程需要一定时间才能使提交显示为已验证?

1
你在 Git 的全局配置和仓库配置中设置的电子邮件地址是什么?它们与你用于 GPG 密钥的电子邮件地址相同吗? - TheGeorgeous
我不确定如何访问repo配置,但全局配置与我分配给键“myemail@address.com”的值匹配。 - Woody1193
3个回答

9

我遇到过同样的问题。只需查看全局配置设置 git config --list

然后将正确的电子邮件地址放入其中 - git config --global user.email <email>


1
我的问题是gpg密钥电子邮件地址与我的git电子邮件地址不匹配。 - Gunar Gessner
我曾经以为git会使用存储在提交作者详细信息中的电子邮件进行签名,但事实并非如此。我不得不像你描述的那样更新我的全局电子邮件首选项。 - Raven

6

我曾经遇到类似的问题,因为我错误地安装和配置了 smimesign,虽然它不是 GPG 密钥指南中的一部分。

我的解决方案如下:

brew uninstall smimesign
git config --global --unset gpg.format
git config --global --unset gpg.x509.program
git config --global user.signingkey [KEY HASH]

[KEY HASH] 在使用 gpg 列出时的位置:

$ gpg --list-secret-keys --keyid-format LONG
/Users/stig/.gnupg/pubring.kbx
------------------------------
sec   rsa4096/...
      [KEY HASH]
uid                 [ultimate] Stig (comment) <stig@example.com>
ssb   rsa4096/...

在下一次提交时,已验证标志立即显示出来。

0

我想将已验证标签推送到远程github,但每次在git remote中推送时都显示未验证

让我简要介绍一下步骤:

#显示所有标签:

git tag

添加本地仓库标签

git tag -a tagname -m "adding tag"

由于在推送(git push --tags)创建的标签上显示未经验证的提交,因此我更改了代码文件并进行了提交,使用已设置和验证的 git GPG。因此,在这个时间点上,我创建了一个标签并更改了代码中的文件。

现在,按照以下步骤进行验证标签或提交 git:

Verify git + gpg
(will prompt for gpg key passphrase on first usage)
echo "test" | gpg --clearsign; the output should look like below:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
test
-----BEGIN PGP SIGNATURE-----
the pgp signature data would show here
-----END PGP SIGNATURE-----
If you see the following error;
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
test
gpg: signing failed: Inappropriate ioctl for device
gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
Try using the following command to fix.
export GPG_TTY=$(tty)
The configurations presented above form the basis of the following UI-based tools and IDEs.
The following sections present the information needed to hook each tool into the local git configuration.
Command line commit syntax
Whenever a commit is made from the developer environment, the following syntax will generate signed commits:
git commit -S -m "your commit message"

标签的其他重要命令:

#删除本地存储库标签

git tag -d tagname

例如:git tag -d v1.3.3

#将新创建的标签推到远程

git push --tags

#删除 Git hub 上的远程标签:

git push --delete origin tagname

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接