Skip to content

Instantly share code, notes, and snippets.

@lantrix
Last active September 14, 2024 17:59
Show Gist options
  • Save lantrix/ee2322de43a260ec2161951e325c8d4f to your computer and use it in GitHub Desktop.
Save lantrix/ee2322de43a260ec2161951e325c8d4f to your computer and use it in GitHub Desktop.
If you have unsigned commits on a branch, you can re-sign them with your GPG uploaded key. Requires GH CLI, gpg installed.

The base branch requires all commits to be signed If you need to setup GPG, you can read our helpful guide.

Then once you have:

  • gpg installed
  • GitHub CLI installed (optional but useful)
  • a key generated for your Name and email, in this example: Lantrix [email protected]
  • your gpg public key uploaded to GitHub
  • You can rebase and re-sign all the commits and force push the branch as a potential solution.
git config --global user.name "Lantrix"
git config --global user.email "[email protected]" # Needs to match the email address of the GitHub GPG key
gh pr checkout 5190 # Your PR number
git rebase -S -i --rebase-merges master #GPG-sign commits on an interactive rebase - mark all commits to be signed as "edit"
git commit --amend '-S' --author "Lantrix <[email protected]>"
git rebase --continue
# For each commit you need to resign
git commit --amend '-S' --author "Lantrix <[email protected]>"
git rebase --continue
# Once all marked commits signed
git push --force
gh pr view --web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment