gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]

前端 未结 30 1928
难免孤独
难免孤独 2020-11-27 23:55

I followed few articles over the pretty attributes on Git 2.10 release note. Going through which upgraded the git to 2.10.0 and made changes to global .gitconfig

相关标签:
30条回答
  • 2020-11-28 00:47

    I've DONE it through this short and easy recipe:

    Auto-sign commits on macOS (Globally and with different IDEs):

    Get your signingkey in this way.

    brew install gnupg gnupg2 pinentry-mac
    git config --global user.signingkey <YOUR_SIGNING_KEY>
    git config --global commit.gpgsign true
    git config --global gpg.program gpg
    

    Put the following in gpg.conf file (edit file with nano ~/.gnupg/gpg.conf command):

    no-tty
    

    Put the following in gpg-agent.conf file (edit file with nano ~/.gnupg/gpg-agent.conf command):

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

    Update:

    You might need to execute killall gpg-agent command after editing the configurations file, gpg.conf, according to the comments. As the self-explanatory command says, this command will terminate the GPG (Gnu Privacy Guard) agent.

    0 讨论(0)
  • 2020-11-28 00:50

    None of the above answers seemed to match my problem. My gpg binary (/usr/local/bin/gpg -> /usr/local/MacGPG2/bin/gpg2) was installed as part of GPG Suite, rather than by brew.

    Nevertheless, I felt that the advice boiled down to: "use whichever gpg binary is the latest available on brew". So I tried:

    brew update
    brew upgrade git
    brew install gpg
    
    # the following are suggestions from brew's Caveats, to make `/usr/local/bin/gpg`
    # point to the brew binary:
    rm '/usr/local/bin/gpg'
    brew link --overwrite gnupg2
    

    I verified that I had correctly changed the gpg upon my $PATH to point to the new executable from brew:

                                                                        
    0 讨论(0)
  • 2020-11-28 00:51

    I've seen similar answers, but nothing exactly like what worked for me. On Linux, I had to kill and restart my gpg-agent with:

    $ pkill gpg-agent
    $ gpg-agent --daemon
    $ git commit ...
    

    This did the trick for me. It looks like you do need to have user.signingkey set to your private key as well from what some other comments are saying.

    $ git config --global user.signingkey [your_key_hash]
    
    0 讨论(0)
  • 2020-11-28 00:51

    In my case, none of the solutions mentioned in other answer worked. I found out that the problem was specific to one repository. Deleting and cloning the repo again solved the issue.

    0 讨论(0)
  • 2020-11-28 00:52

    Make sure you have your email set properly.

    git config --global user.email "user@example.com"
    
    0 讨论(0)
  • 2020-11-28 00:53

    On OS X, using gnupg2 via brew I just had to kill the gpg agent, happens sometimes:

    pkill -9 gpg-agent
    

    And set the env variable if needed:

    export GPG_TTY=$(tty)
    

    See Common GPG problems also and this answer here too.

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