Windows – Why does git complain that no GPG agent is running

gitgnupgwindows

I have the gpg-agent.exe running, but when I try to git commit, it complains that the GPG agent can not be found:

$ gpg-agent --daemon
gpg-agent[17440]: a gpg-agent is already running - not starting a new one

$ git commit -m "foo"

You need a passphrase to unlock the secret key for
user: "Oliver Salzburg <oliver.salzburg@gmail.com>"
4096-bit RSA key, ID 5826006B, created 2016-12-05

gpg: gpg-agent is not available in this session
Enter passphrase:

What is going on?

Best Answer

It is likely that your gpg-agent and gpg binaries are from different packages.

This can happen when you're using Git Bash (which ships with gpg) and you're installing GnuPG4Win additionally. The latter ships with a more recent version.

You can verfiy if this is your problem, by checking the version of both programs:

% gpg-agent --version
gpg-agent (GnuPG) 2.1.7

% gpg --version                                                               
gpg (GnuPG) 1.4.19

If this is your problem, you should tell git which gpg binary to use:

% git config --global gpg.program gpg2
Related Question