Search code examples
windowsgitpowershellgnupg

GPG Commit Signing Stuck on Windows


First some background information about my current setup.

On Windows 11 using PowerShell 7 in Windows Terminal I have the following configuration enabled:

# $HOME\.gitconfig
user.signingkey=F380062B9F847687
commit.gpgsign=true
gpg.program=C:/Program Files (x86)/GnuPG/bin/gpg.exe

I installed GPG via winget with

winget install --id GnuPG.GnuPG

After that I configured the following settings for GNU GPG:

# $HOME\.gnupg\gpg.conf
use-agent
pinentry-mode loopback
# $HOME\.gnupg\gpg-agent.conf
allow-loopback-pinentry

For troubleshooting purposes, I enabled verbose command output for Git:

Set-EnvironmentVariable -Key GIT_TRACE -Value 1 -Scope Process

Kill and restart and gpg-agent just to be sure:

gpgconf --kill gpg-agent && gpgconf --launch gpg-agent

Finally, I attempted to sign a commit with the command:

git commit -m 'test'
00:31:55.001562 exec-cmd.c:243          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
00:31:55.009679 git.c:462               trace: built-in: git commit -m 'test'
00:31:55.024849 run-command.c:661       trace: run_command: 'C:/Program Files (x86)/GnuPG/bin/gpg.exe' -bsau F380062B9F847687

That's where I am stuck now. The Git command never completes and stays in a perpetually indefinite state. There's no error message that I could pick up for further Google searches, and there are also no log files in the $HOME\.gnupg directory (suspicious?) so I did appreciate any other leads that could me help resolve this problem.


Solution

  • I stumbled upon a solution by accident: in my case, the environment variable GNUPGHOME was not set, so added the recommended default record $HOME\.gnupg and now everything works fine again.

    Source for further reading: https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration.html