Before calling the rebase, your configuration should be set up to sign the commits.
# Open the configuration inside your editor
git config --global -e
[user]
name = Your Name
email = [email protected]
signingkey = YOUR_KEY
Rebase and sign the commits:
git rebase -S <parent-ish> --exec "git commit --amend --no-edit"
Rebase, sign the commits, and append Signed-off-by:
inside the commit message:
git rebase --signoff -S <parent-ish>
Amend the previous commit and sign it:
# Short form flags
git commit --amend -S --no-edit
# Long form flags
git commit --amend --gpg-sign --no-edit
Amend the previous commit, sign it, and append Signed-off-by:
inside the commit message:
# Short form flags
git commit --amend -s -S --no-edit
# Long form flags
git commit --amend --signoff --gpg-sign --no-edit
- (
rebase
)--exec
: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---execcmd - (
rebase
)--signoff
: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---signoff - (
rebase
)--gpg-signkey
/-S
: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---gpg-signkeyid - (
commit
)--amend
: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend - (
commit
)--no-edit
: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit - (
commit
)--signoff
/-s
: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff - (
commit
)--gpg-sign
/-S
: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---gpg-signkey-id
Always sign for one repository:
# Inside the repository, run the following command:
git config --local commit.gpgsign true
Always sign for all repositories:
git config --global commit.gpgsign true