Sign your Git Commits in Windows

Install Git if you haven't already.

winget install --id Git.Git

Install The GNU Privacy Guard.

winget install --id GnuPG.GnuPG

Import your key(s) or generate a new one.

gpg --import secret.asc

I don't like the dialog box for password entry and prefer to enter my password on the command line. Add this option to gpg.conf.

"pinentry-mode loopback" >> $env:APPDATA\gnupg\gpg.conf

By default your password is cached for 10 minutes. Add these options to gpg-agent.conf to cache it for 365 days (32850000 seconds).

"default-cache-ttl 32850000" >> $env:APPDATA\gnupg\gpg-agent.conf
"max-cache-ttl 32850000" >> $env:APPDATA\gnupg\gpg-agent.conf

Configure Git to use our gpg.exe instead of the one bundled with Git.

git config --global gpg.program $(Get-Command gpg | Select-Object -Expand Source)