git commit signing failed: secret key not available

前端 未结 9 1603
臣服心动
臣服心动 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:22

    This worked for me on Windows 10 (Note that I use the absolute path to gpg.exe):

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

    This was the error I got prior to the fix:

    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
    
    0 讨论(0)
  • 2020-12-07 13:24

    Using "C:\Program Files\Git\usr\bin\gpg.exe" was the solution for me.
    Had to uninstall kleopatra. With it, it was not working.

    So, summing up;

    • No need for kleopatra, use GIT default instead.

    • git config --global user.signingkey Y0URK3Y
      git config --global commit.gpgsign true
      git config --global gpg.program "C:\Program Files\Git\usr\bin\gpg.exe"
      
    0 讨论(0)
  • 2020-12-07 13:26

    I had the same problem at it was that git name and email store in .gitconfig were different from the ones of the gpg key provided. I changed them in order to match and it started to work.

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

    I'like to complete all these answers, cause I've got many issues with this.

    These exemples use the --global flag, but you can remove it if you want to to these things locally.

    Configure secret key in git

    git config --global user.signingkey 35F5FFB2
    

    Configure witch gpg program tu use in git (optional)

    Some systems (Ubuntu for exemple) can have gpg and gpg2 at the same time. You need to specify you'll use gpg2

    git config --global gpg.program gpg2
    

    Export GPG_TTY (optional)

    It is possible if you use these command in an ssh environment that 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 via :

    export GPG_TTY=$(tty)
    

    Auto enable GPG singing (optional)

    git config --global commit.gpgsign true
    
    0 讨论(0)
  • 2020-12-07 13:36

    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 of gpg2.exe:

    where gpg2.exe
    
    0 讨论(0)
  • 2020-12-07 13:40

    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 every repository.

    git config --global user.signingkey 35F5FFB2
    

    Source: Git Tools - Signing Your Work

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