Skip to content

Instantly share code, notes, and snippets.

@ldez
Last active July 13, 2025 23:28
Show Gist options
  • Save ldez/bf6aa55035e55d09a59942ac0f8cdaac to your computer and use it in GitHub Desktop.
Save ldez/bf6aa55035e55d09a59942ac0f8cdaac to your computer and use it in GitHub Desktop.
How to rebase + GPG sign + Signed-off-by in one line

Set up the user information

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

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

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

References

Extra

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment