Interview Prep/Git & GitHub/Rebase, Cherry-pick and History Rewriting

Compliance asks that every commit on a release branch be signed. Many are not.

AdvancedScenarioRebase, Cherry-pick and History Rewriting
Answer

Situation read → Signing requires rewriting commits, so this is only possible on unshared or new work.

What I'd do →

  1. Configure signing first: git config gpg.format ssh and user.signingkey.
  2. For a private branch: git rebase --exec 'git commit --amend --no-edit -S' origin/main.
  3. For history already shared, do not rewrite. Instead, require signatures from now on via branch protection.
  4. Verify: git log --show-signature -5.

Why → Signatures cover the commit content including parents, so retroactive signing changes every SHA.

Interview tip → Rewriting released history breaks tags and downstream references, so policy goes forward only.

All Git & GitHub questions Roadmap: Git & GitHub

More on Rebase, Cherry-pick and History Rewriting