Run:
brew install gnupg pinentry-macgit config --global user.signingkey <key>git config --global commit.gpgsign truegit config --global gpg.program gpg
Then add the following line to ~/.gnupg/gpg-agent.conf:
pinentry-program /usr/local/bin/pinentry-mac
or, if using the new Homebrew location:
pinentry-program /opt/homebrew/bin/pinentry-mac
One can also install GnuPG from its official site, follow GitHub's guide to create a signing key and then run
git config --global user.signingkey <key> && git config --global commit.gpgsign true && git config --global gpg.program gpg2to auto-sign commits in PyCharm.