- Get
gpg
command
brew install gnupg
- Generate GPG key
gpg --full-generate-key
- List GPG keys for
[email protected]
gpg --list-secret-keys --keyid-format LONG [email protected]
- Copy the GPG key ID that starts with
sec
. In the following example,488652B776349D07
:
sec rsa4096/488652B776349D07 2019-12-14 [SC]
8AAF3B17369BFB6A36171FFA76349D07488652B7
uid [ultimate] Derek Zoladz (None) <[email protected]>
ssb rsa4096/8A3A7957EECFC9AA 2019-12-14 [E]
- Export the public key of that ID
gpg --armor --export 488652B776349D07
-
Copy the public GPG key and it to both GitLab and GitHub accounts
-
Tell Git to use your GPG key to sign commits
git config --global user.signingkey 488652B776349D07
- Tell Git to sign your commits automatically, to avoid using the
-S
flag with every commit
git config --global commit.gpgsign true
- Export GPG key
# temporary
export GPG_TTY=$(tty)
-or-
# add to .bashrc or .zshrc to load at each session
GPG_TTY=$(tty)
export GPG_TTY