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

前端 未结 30 1927
难免孤独
难免孤独 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:39

    If the email assoicated to your GPG key's uid is different to the email you are using in git, you'll need to add another user id to your key OR use a key which email matches exactly.

    You can add another UID by using:

    $ gpg --edit-key

    See for mo https://superuser.com/questions/293184/one-gnupg-pgp-key-pair-two-emails

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

    This started happening all of a sudden for me on Ubuntu, not sure if some recent update did it, but none of the existing issues were applicable for me (I had GPG_TTY set, tried killing the agent etc.). The standalone gpg command was failing with this error:

    $ echo "test" | gpg --clearsign
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    test
    gpg: signing failed: Operation cancelled
    gpg: [stdin]: clear-sign failed: Operation cancelled
    

    I tried running gpg with --debug-all option and noticed the below output:

    gpg: DBG: chan_3 <- INQUIRE PINENTRY_LAUNCHED 27472 gnome3 1.1.0 /dev/pts/6 screen-256color -
    gpg: DBG: chan_3 -> END
    gpg: DBG: chan_3 <- ERR 83886179 Operation cancelled <Pinentry>
    gpg: signing failed: Operation cancelled
    

    The above indicates that there is some issue with the pinentry program. Gpg normally runs pinentry-curses for me, so I changed it to pinentry-tty (I had to aptitude install it first) and the error went away (though I no longer get the fullscreen password entry, but I don't like that anyway). To make this change, I had to add the line pinentry-program /usr/bin/pinentry-tty to ~/.gnupg/gpg-agent.conf and kill the agent with gpgconf --kill gpg-agent (it gets restarted the next time).

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

    Very much like @birchlabs, after a lot of digging/searching I found that it wasn't GPG, but rather GPG Suite. I did cask reinstall gpg-suite and it solved it for me.

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

    Follow the below url to setup signed commit https://help.github.com/en/articles/telling-git-about-your-signing-key

    if still getting gpg failed to sign the data fatal: failed to write commit object

    this is not issue with git ,this is with GPG follow below steps

    1.gpg --version

    1. echo "test" | gpg --clearsign

    if it is showing:

    gpg: signing failed: Inappropriate ioctl for device
    gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
    
    1. then use export GPG_TTY=$(tty)

    4.then again try echo "test" | gpg --clearsign in which PGP signature is got.

    1. git config -l | grep gpg

    gpg.program=gpg commit.gpgsign=true

    6.apply git commit -S -m "commitMsz"

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

    Using cygwin, I recently switched to gpg2. Then I had the same problem for signing with git after setting git config gpg.program gpg2.

    Try echo "test" | gpg2 --clearsign to see whether gpg2 is working. I found it the easiest solution to just set git config gpg.program gpg, because that works. But you will also get a better error this way - e.g. that you need to install pinentry.

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

    I must have accidentally updated gpg somehow because I got this after trying to test if gpg works:

    gpg: WARNING: server 'gpg-agent' is older than us (2.1.21 < 2.2.10)
    gpg: Note: Outdated servers may lack important security fixes.
    gpg: Note: Use the command "gpgconf --kill all" to restart them.
    

    Running gpgconf --kill all fixed it for me.

    Hope this helps someone.

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