Interview Prep/Git & GitHub/GitHub, Actions and Pull Request Issues

`git commit` fails with `error: gpg failed to sign the data` and `fatal: failed to write commit object`.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → commit.gpgsign=true but GPG cannot prompt for the passphrase (no TTY, pinentry missing in a GUI or SSH session), the key expired, or user.signingkey points at a key that does not exist on this machine.

Diagnose →

echo test | gpg --clearsign            # shows the real gpg error
gpg --list-secret-keys --keyid-format=long
git config --get user.signingkey

Fix → Set the TTY and restart the agent:

export GPG_TTY=$(tty)        # add to ~/.bashrc or ~/.zshrc
gpgconf --kill gpg-agent

On macOS install pinentry-mac and set it in ~/.gnupg/gpg-agent.conf. For an expired key, extend it (gpg --edit-key <id> → expire) and re-upload the public key.

Prevent → Consider SSH signing (gpg.format=ssh), which reuses your SSH agent and avoids pinentry issues.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues