Configure GPG for Git on Windows

just.me picture just.me · Oct 28, 2017 · Viewed 14.3k times · Source

I installed Git for Windows including Git Bash on Windows 10 and Gpg4win. By default, I had to re-import all keys I created via Kleopatra into the GPG version built into the Git Bash, and it won't allow me to setup an agent. What I need to do is to automate singing such that I don't need to enter the password every single time, but rather only the first time in a given period of time. How is that possible?

I tried to follow this tutorial, but gpg2 does not use the correct charset when executed from within Git Bash, so it does not recognize keys which contain non-ASCII characters.

Is there any way to solve this problem? What is the best way to use PGP signing with Git on Windows?

Answer

VonC picture VonC · Oct 29, 2017

Update Oct. 2018, as commented below by PHPirate:

λ git --version
git version 2.19.1.windows.1

λ gpg --version
gpg (GnuPG) 2.2.9-unknown
libgcrypt 1.8.3
Copyright (C) 2018 Free Software Foundation, Inc.

No trace of that update in git-for-windows/git/releases


Original answer (2017): By default, Git for Windows includes a gpg1, not gpg2

vonc@bvonc MINGW64 ~/.ssh
$ gpg --version
gpg (GnuPG) 1.4.21

Using a different gpg is indeed recommended:

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

Try again with the latest Git for Windows with UTF-8 set in locale.
Try a Git simplified path to rule out any interference from other programs.