I followed few articles over the pretty attributes on Git 2.10 release note. Going through which upgraded the git to 2.10.0 and made changes to global .gitconfig
I've DONE it through this short and easy recipe:
Auto-sign commits on macOS (Globally and with different IDEs):
Get your signingkey
in this way.
brew install gnupg gnupg2 pinentry-mac
git config --global user.signingkey <YOUR_SIGNING_KEY>
git config --global commit.gpgsign true
git config --global gpg.program gpg
Put the following in gpg.conf
file (edit file with nano ~/.gnupg/gpg.conf
command):
no-tty
Put the following in gpg-agent.conf
file (edit file with nano ~/.gnupg/gpg-agent.conf
command):
pinentry-program /usr/local/bin/pinentry-mac
Update:
You might need to execute killall gpg-agent
command after editing the configurations file, gpg.conf
, according to the comments. As the self-explanatory command says, this command will terminate the GPG (Gnu Privacy Guard) agent.
None of the above answers seemed to match my problem. My gpg
binary (/usr/local/bin/gpg -> /usr/local/MacGPG2/bin/gpg2
) was installed as part of GPG Suite, rather than by brew.
Nevertheless, I felt that the advice boiled down to: "use whichever gpg
binary is the latest available on brew". So I tried:
brew update
brew upgrade git
brew install gpg
# the following are suggestions from brew's Caveats, to make `/usr/local/bin/gpg`
# point to the brew binary:
rm '/usr/local/bin/gpg'
brew link --overwrite gnupg2
I verified that I had correctly changed the gpg
upon my $PATH
to point to the new executable from brew:
I've seen similar answers, but nothing exactly like what worked for me. On Linux, I had to kill and restart my gpg-agent
with:
$ pkill gpg-agent
$ gpg-agent --daemon
$ git commit ...
This did the trick for me. It looks like you do need to have user.signingkey
set to your private key as well from what some other comments are saying.
$ git config --global user.signingkey [your_key_hash]
In my case, none of the solutions mentioned in other answer worked. I found out that the problem was specific to one repository. Deleting and cloning the repo again solved the issue.
Make sure you have your email set properly.
git config --global user.email "user@example.com"
On OS X, using gnupg2
via brew I just had to kill the gpg agent, happens sometimes:
pkill -9 gpg-agent
And set the env
variable if needed:
export GPG_TTY=$(tty)
See Common GPG problems also and this answer here too.