657 B
657 B
生成新密钥
gpg --full-generate-key
- 选择密钥类型:默认
RSA and RSA(按回车) - 密钥长度:建议
4096 - 有效期:可以设为
0(永不过期)或指定年限 - 输入你的 真实姓名 和 邮箱地址(必须与 Git 配置中的 user.email 一致!)
查看已有的 GPG 密钥
gpg --list-secret-keys --keyid-format=long
Git 使用这个 GPG 密钥
git config --global user.signingkey xxx
配置 Git 默认签名提交
git config --global commit.gpgsign true
导出公钥并添加到 GitHub/GitLab 等平台
gpg --armor --export xxxxx