If no filtering on commit is needed, then it is preferred to use rebase than filter-branch:
git rebase -i master --exec 'git commit --amend --no-edit --no-verify -S --reset-author'
Else, you can leave untouched the commits you don't own.
Set the following alias in ~/.gitconfig
(replace your@address.com
with your email address):
resign = "!_() { : git checkout ; [ \"$#\" -eq 0 ] && echo 'Usage: resign <rev-list>' && exit 2; \
git filter-branch --commit-filter ' \
if [ \"$GIT_COMMITTER_EMAIL\" = \"your@address.com\" ]; then git commit-tree -S \"$@\"; else git commit-tree \"$@\"; fi' $1; }; _"
Then for instance, to resign all your commits in the current branch pulled from master, do:
git resign master..
Credits to previous answers by
BarryMode and
Roberto Leinardi
git config commit.gpgsign true
.