Automatically Sign Commits Using GPG Suite on macOS
To make my commits marked as “verified” on GitHub, I tried to sign them locally using GPG. It worked fine using the following command line command:
1 | > git commit -S -m your commit message |
But when I tried to sign commits within JetBrains IDEs, like Clion, things did not work out so easily. JetBrains IDEs do not provide native supports/integrations for GPG. So I need to make use of GPG Suite to sign commits automatically without being prompted for password from the terminal. This post records how to do so.
Installing GPG Suite
1 | > brew cask install gpg-suite |
Generating a GPG key
1 | > gpg --full-generate-key |
Choose RSA and RSA
for encryption method, 4096
for key size.
1 | > gpg --list-secret-keys --keyid-format LONG |
Copy the GPG key, beginning with -----BEGIN PGP PUBLIC KEY BLOCK-----
and ending with -----END PGP PUBLIC KEY BLOCK-----
. Add the GPG key to GitHub account.
Configuring Automated Signing
1 | > git config --global user.signingkey B31AD9AD2B5CFABD |
Add export GPG_TTY=$(tty)
to .zshrc
, .bashrc
and etc.
When you store a password in macOS keychain, pinentry, the program used to ask for your password, will never again ask for that password. macOS will remember this password and automatically use it when needed. That means you will no longer see the pinentry dialog querying for your password. The password is protected with your macOS user password.
Choose ‘Store in OS X Keychain’ option when the pinentry dialog asks for the password.
Automatically Sign Commits Using GPG Suite on macOS
https://blog.zzhou612.com/2019/02/26/automatically-sign-commits-using-gpg-suite-on-macos/