LOADING

加载过慢请开启缓存 浏览器默认开启

使用ssh密钥代替gpg密钥对git提交签名

2025/9/28 2025/10/1 笔记 github

如果本地没有 ssh 密钥

ssh-keygen -t ed25519 -C "your_email@example.com"

转到仪表盘-settings-SSH and GPG keys-New SSH key
Key typeSigning Key粘贴刚才生成之后输出的.pub 公钥中的内容

配置 Git 使用 SSH 对提交和标记签名
将 /PATH/TO/.SSH/KEY.PUB 替换为要使用的公钥路径

git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/KEY.PUB

[!TIP]
若要将 Git 客户端配置为默认对本地存储库的提交进行签名,请在 Git 版本 2.0.0 及更高版本中,运行 git config commit.gpgsign true。 要在计算机上的任何本地存储库中默认对所有提交进行签名,请运行git config --global commit.gpgsign true