任何人都可以用你的名字和邮箱设置 git config,推送提交,在 GitHub 上显示为你的作品。唯一的区别:没有 "Verified" 徽章。
任何人都可以用你的名字和邮箱设置 git config,推送提交,在 GitHub 上显示为你的作品。唯一的区别:没有 "Verified" 徽章。
Git 提交只包含作者名字和邮箱字符串,没有密码学验证。GitHub 不验证提交者身份。
# 1. 生成 GPG 密钥
gpg --full-generate-key
# 2. 获取密钥 ID
gpg --list-secret-keys --keyid-format=long
# sec ed25519/XXXXXXXXXXXXXXXX 2026-01-01
# 3. 导出公钥
gpg --armor --export XXXXXXXXXXXXXXXX
# 4. 添加到 GitHub Settings → SSH and GPG keys
# 5. 配置 Git 使用 GPG
git config --global user.signingkey XXXXXXXXXXXXXXXX
git config --global commit.gpgsign true
git config --global tag.gpgsign true# GitHub 也支持 SSH 签名
# 1. 使用现有 SSH 密钥
git config --global gpg.format ssh
# 2. 指定签名密钥
git config --global user.signingkey ~/.ssh/id_ed25519.pub
# 3. 添加到 GitHub Settings → SSH and GPG keys → Signing keys# 提交后在 GitHub 上查看
# 应该看到 "Verified" 徽章
git log --show-signature# 仓库级强制(GitHub Settings → Branches → Branch protection rules)
# 勾选 "Require signed commits"gpg --full-generate-key
echo "Verification passed: fix command exited 0"Expected Output: command completes without error, then Verification passed is printed. (Checks: gpg --full-generate-key)