When working with a repo that enforces signed commits, a broken GPG setup can block merges, rebases, and resets. If you need to fix GPG and reset Git to a working state, move quickly and apply clean, verifiable changes.
Common causes of GPG Git errors:
- Expired GPG keys or missing secret keys
- Incorrect
user.signingkeyin Git config gpg-agentnot running or using the wrong socket- Git not pointing to the right GPG binary
- Environment variables broken after an update
To clear a bad commit and re‑sign with GPG:
- Check if your GPG key is available:
gpg --list-secret-keys --keyid-format=long
Find the correct key ID.
- Configure Git to use it:
git config --global user.signingkey <KEY_ID>
git config --global gpg.program gpg
- Verify GPG works:
echo "test"| gpg --clearsign
- If a commit failed and remains in history, reset to before it:
git reset --hard HEAD~1
- Re-commit with signing enabled:
git commit -S -m "Your commit message"
For a full rebase with GPG re‑signing on each commit: