I'm having some trouble setting up GPG commit signing with github after performing a windows reinstall.
Issue:
When commiting, GPG signing fails returning this error:
gpg: skipped "993E2EFC8503C42F": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
Everything I have googled about this issue all point to setting gpg.program
to the location of the GnuPG gpg executable ("C:\Program Files (x86)\GnuPG\bin\gpg.exe"
) Which sadly, has not solved my issue.
Performing gpg --list-secret-keys --keyid-format=long
in git bash returns my gpg keys, however performing the same command in powershell or cmd, does not, which i believe might be my issue, although i dont know how to go about fixing this.
Steps already taken:
- installed GPG4Win from here
- installed git from here
- followed the GPG setup guide by github
- set
git config --global user.name "name..."
andgit config --global user.email "email"
- set
git config --global user.signingkey
to my gpg key - set
git config --global gpg.program
to"C:\Program Files (x86)\GnuPG\bin\gpg.exe"
as described by various other online tutorials and answers - set
git config --global commit.gpgsign
to true
- already looked at "No secret key" error when signing git commit on Windows, gpg: skipped "N": secret key not available and git commit signing failed: secret key not available
Expected result:
Successfully submit a verified commit
bonus info
- Git version: 2.36.0.windows.1
- OS: windows 11 22000.613
CodePudding user response:
I've managed to figure it out!
I'm ultimately not quite sure what the issue was specifically, however, after uninstalling GPG4Win and Git, then only reinstalling Git and going through the GPG setup process, I'm now able to perform verified commits. this is using Gits bundled GPG program and no other GPG related installation.
not sure if this will help anyone else, but if you're on windows having this issue, try running through the gpg setup process WITHOUT GPG4Win installed and just use gits bundled GPG executable.
remember to set commit.gpgsign
to true and tell git your signing key like so git config --global user.signingkey "your key id"
if you only want to set the signing key for specific project you can cd to the project directory and run the same command WITHOUT the --global
tag.