Working with signed commits in Git can be frustrating during a rebase, especially when GPG prompts interrupt your flow. But setting up GPG to work seamlessly avoids these stalls and keeps your history clean and trusted.
Why GPG matters in Git rebase
GPG adds cryptographic signatures to commits, proving authorship and integrity. In a rebase, Git rewrites commits. If your project enforces commit.gpgSign or git config user.signingkey, Git replays each commit and expects a valid signature. Without proper GPG configuration, the rebase halts and prompts for every commit.
Configuring GPG for uninterrupted rebases
- Install and verify GPG:
gpg --version
Ensure you’re using GPG 2.x or higher.
- Generate or import your key:
gpg --full-generate-key
Or import an existing key if you already have one.
- List keys and get the key ID:
gpg --list-secret-keys --keyid-format LONG
Note the long key ID tied to your email.
- Set Git to use your GPG key:
git config --global user.signingkey <YOUR_KEY_ID>
git config --global commit.gpgSign true
- Enable GPG agent caching:
Configure your ~/.gnupg/gpg-agent.conf with:
default-cache-ttl 3600
max-cache-ttl 7200
Restart the agent:
gpgconf --kill gpg-agent
Rebasing with GPG signatures
When you run:
git rebase main
Git will replay commits with signatures intact. If your GPG agent caches the passphrase, you won’t see repeated prompts. This preserves the signed state across the new commit history and satisfies signature verification checks.
Troubleshooting common GPG rebase errors
- If Git cannot find
gpg, set its path:
git config --global gpg.program $(which gpg)
- If signatures break mid-rebase, run:
git rebase --abort
Fix your GPG setup, then retry.
- If your CI/CD fails due to signature requirements, ensure every rebased commit is signed before pushing.
A smooth GPG Git rebase workflow means less manual signing, fewer broken histories, and builds that pass on the first try.
Set it up once, and you’ll sign every commit without thinking. See it live in minutes at hoop.dev and keep your Git pipelines running without interruptions.