Git error - gpg failed to sign data

前端 未结 26 1525
遇见更好的自我
遇见更好的自我 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: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

提交回复
热议问题