Back

linux - 使用 git commit signing git commit 签名

发布时间: 2022-11-24 01:50:00

refer to:

https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification

https://gist.github.com/ankurk91/c4f0e23d76ef868b139f3c28bde057fc 

https://www.linuxjournal.com/content/signing-git-commits

1. 创建一个新的gpg: 

# Ubuntu
sudo apt-get install gpa seahorse
# MacOS with https://brew.sh/
brew install gpg

2. 生成: gpg --gen-key

3. 列出来:

gpg --list-secret-keys --keyid-format=long

/home/siwei/.gnupg/pubring.kbx
------------------------------
sec   rsa3072/E056D7D3A36CE2FA 2023-01-06 [SC] [expires: 2025-01-05]
      3919CC5D8A047CB4FF30C669E056D7D3A36CE2FA
uid                 [ultimate] yates 
ssb   rsa3072/38B2E703BCAB2FEF 2023-01-06 [E] [expires: 2025-01-05]

4. 复制上面的 E056D7D3A36CE2FA  ,然后列出它的完整内容:

$ gpg --armor --export E056D7D3A36CE2FA

结果如下图;

5. 把上图红框的内容,粘贴到github中去。具体路径为:settings -> ssh and gpg keys -> new gpg key

https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-gpg-key-to-your-github-account

填好保存即可:

修改本地的 .git/config 或者 ~/.gitconfig

Back