Git error - gpg failed to sign data

前端 未结 26 1456
遇见更好的自我
遇见更好的自我 2020-12-07 07:19

I just started using git and I install git and gpg via homebrew. For some reason, I get this error when i do git commit I looked at so many other stackoverflow

相关标签:
26条回答
  • 2020-12-07 07:39

    This error can also occur when your GPG key has expired. Generating a new key and adding it to Git should resolve this.

    0 讨论(0)
  • 2020-12-07 07:40

    I had made a git key with 3 separate keys for certify / sign / encrypt & the key showed as expired in the future (after working fine for a few days):

    pub   rsa4096/4CD1E9DA 2017-04-26 [C] [expired: 2017-04-28]
          Key fingerprint = 4670 59C1 7592 08B8 7FA5  313B 2A42 B6A6 4CD1 E9DA
    uid         [ expired] Stuart Cardall (GIT Development Keys) <xxxxxx>
    sub   rsa4096/5195E715 2017-04-26 [E] [expired: 2019-04-26]
    sub   rsa4096/DB74C297 2017-04-26 [S] [expired: 2019-04-26]
    sub   rsa2048/A3913A3C 2017-04-28 [] [expired: never     ]
    

    made a new key without adding separate subkeys to solve the problem.

    0 讨论(0)
  • 2020-12-07 07:40

    May be your Git config was set gpgsign = true. Try to set it to false if you dont want asign your commits. Go to your repository folder and change the file

    nano .git/config

    From this...

    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        url = git@bitbucket.org:yourrepo/project.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    [user]
        signingkey = <GPG-KEY>
    [commit]
        gpgsign = true
    

    To this...

    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        url = git@bitbucket.org:yourrepo/project.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    [user]
        signingkey = <GPG-KEY>
    [commit]
        gpgsign = false
    
    0 讨论(0)
  • 2020-12-07 07:41

    I solved the problem installing brew install gpg2 then doing git config --global gpg.program gpg2

    0 讨论(0)
  • 2020-12-07 07:41

    For me a simple brew unintstall gnupg && brew cask reinstall gpg-suite solves the issue.

    It uninstalls the (in my case) manually homebrew-istalled gpg and reinstalls the whole GPG Suite.

    0 讨论(0)
  • 2020-12-07 07:44

    Refer to @sideshowbarker, and @Xavier Ho solution, I solved my problem via following steps.

    Assume gpg2 installed by brew,

    git config --global gpg.program gpg2
    brew install pinentry
    gpgconf --kill gpg-agent
    gpg2 -K --keyid-format SHORT
    // no key found then generate new one
    gpg2 --gen-key
    
    gpg2 -K --keyid-format SHORT 
    
               
    

    .../.gnupg/pubring.gpg

    sec rsa2048/0A61C6FC 2017-06-29 [SC] [expires: 2019-06-29]

    git config --global user.signingkey 0A61C6FC
    

    Reminded by my colleague, need to append

    export GPG_TTY=$(tty)
    

    to ~/.zshrc if using zsh, else append to ~/.bash_profile


    For macOS,

    the gpg2 is combined with gpg in brew and hence the gpg command is pointed to gpg2

    brew install gpg2
    

    brew info gpg

    gnupg: stable 2.2.6 (bottled)

    git config --global gpg.program gpg
    gpg -K --keyid-format SHORT 
    

    and there has pinentry-mac for passphrase entry

    brew install pinentry-mac
    vim ~/.gnupg/gpg-agent.conf
    

    Add line

    pinentry-program /usr/local/bin/pinentry-mac

    Reminded by my colleague, need to append

    export GPG_TTY=$(tty)
    

    to ~/.zshrc if using zsh, else append to ~/.bash_profile

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