!!! For M1/M2 apple silicon see this comment:
For MacOS | Mojave | High Sierra
brew upgrade gnupg
brew install pinentry-mac
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent && gpg-agent --daemon
git config --global gpg.program gpg
git config --global commit.gpgsign true
This seemed to work for me on my MacBook Pro (macOS Ventura) with Apple M1 Pro chip! But I had to do the following extra things:
brew reinstall gnupgbefore the upgrade command in Step 1echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conffor Step 3, I had to type inecho "pinentry-program opt/homebrew/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf(I found the path by runningwhich pinentry-macin the terminal)git config --global gpg.program gpgin Step 5, I had to type ingit config --global gpg.program /opt/homebrew/bin/gpg(I found the path by runningwhich gpgin the terminal)For further context, after I added git tracing to my commit:
GIT_TRACE=1 git commit -a -m 'signing test',the error message I got was: