gpg failed to sign 🌿 Git

error: gpg failed to sign the data — fatal: failed to write commit object

Commit signing is enabled but GPG couldn’t sign — no TTY for the passphrase, wrong key, or agent not running.

Seen on: Git

Meaning

commit.gpgsign=true requires a working gpg setup. GUIs and IDEs can’t prompt for the passphrase without pinentry configured.

Common causes

  • GPG_TTY not set / pinentry missing
  • Key expired or not in the keyring
  • user.signingkey wrong

⚡ Quick fix

  1. export GPG_TTY=$(tty) (add to your shell profile)
  2. Check keys: gpg --list-secret-keys --keyid-format=long
  3. Or sign with SSH keys (gpg.format ssh)

Detailed fix by platform

Git

  1. git config --global gpg.format ssh && git config --global user.signingkey ~/.ssh/id_ed25519.pub

How to diagnose

  1. Test — echo test | gpg --clearsign
  2. Key — Matches user.signingkey?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.