How to retroactively sign all commits in a branch
If you haven’t set up GPG signing, check out my previous post on this here.
Say you created a new branch from
my-branch. This guide will help you to sign all of the commits that are in
my-branch that are not in
For starters, do a
git fetch origin so that we are up to date with remotes. Be on
my-branch. Ensure that you are rebased correctly from the
main branch. This is not so important but will keep things clean and make it easy to merge later.
git rebase origin/main
Resolve conflicts, if any. Ensure clean state. Now to retroactively sign commits on
git rebase --exec 'git commit --amend --no-edit -n -S' -i origin/main
my-branch basically what you are saying here is that:
- Start an interactive rebase from the last known commit that is on
origin/main, rolling back temporarily.
- For every commit, execute (
--exec) git commit command, amending each commit without modifying its contents and signing every commit
Hope this helps.