": secret key...">

Git commit commit error: secret key unavailable

I get this error when trying to commit using Git.

gpg: skipped "name <name@mail.com>": secret key not available gpg: signing failed: secret key not available error: gpg failed to sign the data fatal: failed to write commit object 

I created a new key as shown below, but it still gives the same error

 gpg --list-keys ~/.gnupg/pubring.gpg -------------------------------- pub 2048R/35F5FFB2 2016-04-23 uid name (New key) <name@mail.com> sub 2048R/112A8C2D 2016-04-23 

The secret key is the same as above

I found this GPG key generation for git tags and followed the steps, but it still doesn't work, any idea?

+46
git
Apr 23 '16 at 11:54 on
source share
6 answers

You need to configure the secret key before using it.

 git config user.signingkey 35F5FFB2 

Or declare it globally if you want to use the same key for each repository.

 git config --global user.signingkey 35F5FFB2 

Source: https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work

+50
Apr 23 '16 at 13:49 on
source share

What worked for me was adding

 git config --global gpg.program "C:/Program Files (x86)/GNU/GnuPG/gpg2.exe" 

If you want to find the full path to gpg2.exe:

 where gpg2.exe 
+37
Apr 13 '17 at 13:29
source share

This worked for me on Windows 10

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

It was a mistake that I received before fixing

gpg: skipped "3E81C*******": secret key not available gpg: signing failed: secret key not available error: gpg failed to sign the data fatal: failed to write commit object

+14
Jun 24 '18 at 11:18
source share

I like to fill out all of these answers because I have a lot of problems with this.

These examples use the --global flag, but you can remove it if you want these things to be local.

Configure secret key in git

 git config --global user.signingkey 35F5FFB2 

Configure witch gpg tu program for use in git (optional)

Some systems (e.g. Ubuntu) may have gpg and gpg2 at the same time. You need to indicate that you will use gpg2

 git config --global gpg.program gpg2 

Export GPG_TTY (optional)

Perhaps if you use this command in an ssh environment, you have the following error: Inappropriate ioctl for device or gpg: échec de la signature : Ioctl() inapproprié pour un périphérique . This can be fixed with:

 export GPG_TTY=$(tty) 

GPG auto-on singing (optional)

 git config --global commit.gpgsign true 
+8
Nov 28 '17 at 13:42 on
source share

You must set the GNUPGHOME variable. Without it, GnuPG cannot find your keys.

 # On unix add it to your path # On windows it will usually be under: <drive>:\Users\<username>\AppData\Roaming\gnupg 

On Unix, it just adds it to the path.
On Windows, you should open the control panel and set it as

 System Variable Name: GNUPGHOME Path: <drive>:\Users\<username>\AppData\Roaming\gnupg 
+4
Apr 23 '16 at 1:39 on
source share

You may need to clone your own repository where you have rights. I had this problem when I cloned another person's repository.

-3
Mar 09 '17 at 9:45
source share



All Articles