gpg secret key not found

Hello. I try to make my first github repo. I have created both a ssh and gpg key. When i try to run git commin -m “message” in vs code i get this error: gpg: skipped “user user@gmail.com”: No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
When i run gpg --list-secret-keys on git bash though i see that in the directory that gpg searches the file with the key is there. The file name is pubring.kbx. Also when i try to show my secret key in git bash gpg --list-secret-keys --keyid-format=long i get as output the secret key. I have no other keys made only one so what could be the problem?

Hi @predator,

can you try to sign a random file? Does that work? You can also read this thread and try the things that are mentioned there: Gpg decryption fails(no secret key found) after upgrade from gpg4win 3.1.1->4.3.0

BTW: Which version of GnuPG are you using?

Thanks for replying @cklassen, I have downloaded gpg4win 4.3.1 and i never had a newer version. I have seen the article you linked that’s why i wrote to this forum because it didn’t work. And what do you mean by try to sign a random file? How do i do that?

Does the public part of your secret key has the email address that github has
as part of its UIDs? (Can you see the same email address if you list the
pubkeys?)

Yes i have the same email address both for github and the public key. @bernhard

Hi @predator
if your secret key can be seen on the command line (as you have reported)
and is usable (which is something you can test), the next idea I have is that git is using different settings or a different installation of GnuPG.
Maybe you can check your git installation and see if there is another gpg.exe coming with it? Or check the git commands for configuring the call to gpg and change it to a fixed full length path?

To test that you can use your secret key, you could just sign something with it. Maybe a simple file. On the command line that would be like

echo Hello > hi.txt
gpg --sign hi.txt