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 →
- Configure signing first:
git config gpg.format sshanduser.signingkey. - For a private branch:
git rebase --exec 'git commit --amend --no-edit -S' origin/main. - For history already shared, do not rewrite. Instead, require signatures from now on via branch protection.
- 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.
More on Rebase, Cherry-pick and History Rewriting
Your PR branch has ten commits like "wip", "fix typo", "oops". How do you clean it up before review?BeginnerYou want the database migration commit to come before the code that uses it.BeginnerA critical fix on `main` must go to the `release/4.1` branch only.BeginnerYou must backport a feature made of 6 commits, including one merge commit.IntermediateBranch B was built on top of branch A. A was squash-merged into `main`, and now B shows A's commits again.IntermediateDuring review you get ten small change requests on old commits. How do you apply them cleanly?Intermediate