git commit signing failed: secret key not available

前端 未结 9 1604
臣服心动
臣服心动 2020-12-07 12:41

I am getting this error when trying to commit using Git.

gpg: skipped \"name \": secret key not available
gpg: signing failed: secret ke         


        
相关标签:
9条回答
  • 2020-12-07 13:42

    You have to set the variable GNUPGHOME. Without it, GnuPG is not able to 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 simply adding it to the path.
    On Windows you have to open the control panel and set it as

    System Variable
      Name: GNUPGHOME
      Path: <drive>:\Users\<username>\AppData\Roaming\gnupg
    
    0 讨论(0)
  • 2020-12-07 13:45

    I had a situation in which the same was happening to me in a Windows 10 machine.

    $ git commit -m "Improve logging, imports and show time executed"
    gpg: signing failed: Operation cancelled
    gpg: signing failed: Operation cancelled
    error: gpg failed to sign the data
    fatal: failed to write commit object
    

    The commands "C:\Program Files (x86)\GnuPG\bin\gpg.exe" --list-secret-keys --keyid-format LONG and gpg --list-secret-keys --keyid-format LONG where giving me complete different results!

    $ where gpg
    C:\Program Files\Git\usr\bin\gpg.exe
    C:\Program Files (x86)\GnuPG\bin\gpg.exe
    

    The main reason was related to previous answers but on a different sense:

    • I was creating the gpg keys using the git (configured path) version of GPG
    • Git was configured to use the downloaded version of gpg for the commit.
    • Seems GPG implementations use their own certificate database and storage.

    I hope this can help anyone that stumbles on this message and previous answers do not solve ther issue.

    0 讨论(0)
  • 2020-12-07 13:47

    Maybe you need to clone your own repository where you have rights. I had this issue when I cloned the repository of another person.

    0 讨论(0)
提交回复
热议问题