brew install gnupg
gpg --gen-key
gpg --list-key
/Users/xyz/.gnupg/pubring.kbx
-------------------------------
pub rsa2048 2020-05-28 [SC] [expires: 2022-05-28]
XXXXXXXXXXXXXXXF44D6E037E8
uid [ultimate] fname lname <[email protected]>
sub rsa2048 2020-05-28 [E] [expires: 2022-05-28]
Copy the key id (XXXXXXXXXXXXXXXF44D6E037E8) to use it in the next step.
git config --global commit.gpgsign true
git config --local user.signingKey XXXXXXXXXXXXXXXF44D6E037E8
In case you experienced issues when sigining a commit/tag:
brew install pinentry-mac
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent