GPG

Sign commit with GPG

Install GPG

brew install gnupg

Import GPG Key

gpg --import private.key

List keys

gpg --list-keys

# Output
/Users/muxinqi/.gnupg/pubring.kbx
---------------------------------
pub   rsa4096 2020-12-25 [SC] [expires: 2024-12-25]
      ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN
uid           [ unknown] muxinqi <[email protected]m>
uid           [ unknown] muxinqi <[email protected]m>
sub   rsa4096 2020-12-25 [E] [expires: 2024-12-25]
sub   rsa4096 2021-03-20 [S] [expires: 2024-12-25]

Set trust level

Restart gpg-agent

Check trust level

Sign commit with the key

Add the following line to the end of ~/.zshrc

Now, close and re-open the terminal, could sign commit with:

Sign commits automatically

To avoid having to re-enter the password after a certain period of time, using pinentry-mac to solve this problem

Restart gpg-agent

References

Last updated