Is there a way to gpg sign all previous commits?

My approach is

git rebase --exec "git commit --amend --no-edit -n -S" -i 8fd7b22

All commits started from the next after 8fd7b22 will be rebased with no changes except signing. To change all commits started from the very first one you may use --root (since Git v1.7.12):

git rebase --exec "git commit --amend --no-edit -n -S" -i --root

To spread changes to the remote I use

git push --force

Note, this will update “gpg made” date-time and, for example, GitHub will treat it as commit date. Git itself persists both original and new dates, git log --show-signature gives clear picture of when the original commit was made and when it was signed for the last time.

Leave a Comment