# Fixing Gpg4win “secret key not available” error

After a fresh installation of Visual Studio with bundled Git for Windows + Gpg4Win, followed by setting up of a new GPG key for signing of commits, the following was reported when trying to sign a commit:

gpg: skipped "name m.otorowski@xxxxx.xyz": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign the data
fatal: failed to write commit object

The message can be misleading, the keys are actually all correct. The problem can be solved by changing the path to GPG signer, which on my machine was (incorrectly) set to c:\Program Files\Git\usr\bin\gpg.exe. The file exists, but it is not the one that should be used here – the correct one is C:\Program Files (x86)\GnuPG\bin\gpg.exe.

Executing the following command which sets the correct path helps:

git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"