To sign all your commits in the Git Pull Request (PR), you can use a combination of git rebase
and git commit --amend
. Here are the steps:
-
Before starting, make sure you've configured Git to use your signing key. You can do this with:
git config --global user.signingkey YOUR_SIGNING_KEY git config --global commit.gpgsign true
Replace
YOUR_SIGNING_KEY
with your GPG key ID. -
Then you need to start an interactive rebase with the parent of your first commit. If you don't know what commit that is, you can use
git log
to display your commit history. Once you have your commit hash, start the rebase:git rebase -i YOUR_COMMIT_HASH^
-
In the interactive rebase screen, change all the
pick
commands toedit
for the commits you want to sign. Then save and exit the file (in vim, this is done with:wq
). -
Git will now go through all the commits you marked as
edit
, and pause after each one. You can then amend and sign each commit like this:git commit --amend --no-edit --gpg-sign
-
Once you're done with a commit, you can tell Git to continue to the next one with:
git rebase --continue
-
Git will then pause again for the next commit. Repeat the process until you've signed all the commits.
-
If you already pushed your unsigned commits to the server, you'll have to force push your newly signed commits with:
git push origin YOUR_BRANCH_NAME --force
Replace
YOUR_BRANCH_NAME
with the name of your branch.
This should sign all the commits you've specified. Be aware that this will rewrite your Git history, which can cause problems for other people if they're also working on this branch. It's a good idea to let them know what you're doing so they can rebase their changes on top of your newly signed commits.