{"data":{"slug":"discovered-bd26dc6a92d47a2b64a7c078957ec9532267ac6ecc61ce15","title":"Merge a GitHub PR Locally (Preserving GPG Signatures)","summary":"Merge a GitHub pull request into the main branch using a local fast-forward merge, ensuring all commits are GPG-signed and preserving the original commit history.","url":"https:\/\/skillshunter.net\/skills\/discovered-bd26dc6a92d47a2b64a7c078957ec9532267ac6ecc61ce15","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-bd26dc6a92d47a2b64a7c078957ec9532267ac6ecc61ce15","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-bd26dc6a92d47a2b64a7c078957ec9532267ac6ecc61ce15.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-bd26dc6a92d47a2b64a7c078957ec9532267ac6ecc61ce15\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before proceeding, ensure that the current branch is up to date with the remote main branch and that all commits in the PR are GPG-signed. If there are uncommitted changes in the working directory, they will be stashed and restored after the merge.","instructions":"---\nname: pr-merge\ndescription: Merge a PR locally with fast-forward to preserve GPG-signed commits, then clean up.\nallowed-tools: Bash(git status:*), Bash(git log:*), Bash(git diff:*), Bash(git fetch:*), Bash(git checkout:*), Bash(git rebase:*), Bash(git merge:*), Bash(git push:*), Bash(git branch:*), Bash(git rev-parse:*), Bash(git symbolic-ref:*), Bash(git stash:*), Bash(git remote:*), Bash(gh pr:*), Bash(python ~\/.claude\/skills\/shared\/push.py:*), Bash(python3 ~\/.claude\/skills\/shared\/push.py:*), Bash(python ~\/.claude\/scripts\/review_scope.py status), Bash(python3 ~\/.claude\/scripts\/review_scope.py status), Bash(python ~\/.claude\/scripts\/review_scope.py forecast), Bash(python3 ~\/.claude\/scripts\/review_scope.py forecast), Read\n---\n\n# Merge PR Locally (Preserving GPG Signatures)\n\nMerge a GitHub PR into main using a local fast-forward merge so the original\nGPG-signed commit(s) land on main with their signatures intact. GitHub's merge\nUI re-creates commits with GitHub's own key, losing the author's GPG signature\nand showing \"Unverified\" on repos that enforce signing.\n\nRead `~\/.claude\/skills\/shared\/bash-rules.md` for bash command constraints.\n\n## Context\n- Current branch: !`git rev-parse --abbrev-ref HEAD`\n- Working tree status: !`git status --short`\n- Open PRs: !`gh pr list --state open --json number,title,headRefName`\n\n## Arguments\n\nOptional: PR number or branch name. If omitted, auto-detect from the current\nbranch or find the single open PR.\n\n## Workflow\n\n### Step 1: Identify the PR\n\n1. If a PR number was given as argument, use it directly.\n\n2. If a branch name was given, find its PR:\n   ```\n   gh pr list --head <branch-name> --json number,title,state --jq '.[0]'\n   ```\n\n3. If no argument was given, try the current branch:\n   ```\n   git rev-parse --abbrev-ref HEAD\n   ```\n   If not on main, look up its PR. If on main, list open PRs and pick the\n   single one (ask the user if there are multiple):\n   ```\n   gh pr list --state open --json number,title,headRefName\n   ```\n\n4. Fetch PR details:\n   ```\n   gh pr view <number> --json number,title,state,headRefName,baseRefName,commits,reviews,statusCheckRollup\n   ```\n   Abort if the PR is not open or if checks are failing.\n\n### Step 2: Verify readiness\n\n1. Confirm the PR has passing checks (or no required checks).\n2. Show the PR title, branch, and commit count to the user.\n3. Verify all PR commits are GPG-signed:\n   ```\n   git fetch origin <branch-name>\n   git log origin\/main..origin\/<branch-name> --format=\"%h %G? %s\"\n   ```\n   `G` = good signature. Warn if any commit is unsigned (`N`) or has a bad\n   signature (`B`).\n\n### Step 3: Stash uncommitted changes\n\nIf `git status` shows uncommitted changes (staged or unstaged), stash them\nbefore switching branches:\n```\ngit stash\n```\nRemember to pop the stash at the end (Step 5).\n\n### Step 4: Fast-forward merge\n\npr-create already rebases onto main before pushing, so the branch should\nbe fast-forwardable. If not, rebase first.\n\n1. Ensure main is up to date:\n   ```\n   git fetch origin main\n   git checkout main\n   git merge origin\/main --ff-only\n   ```\n\n2. Fast-forward merge the PR branch:\n   ```\n   git merge <branch-name> --ff-only\n   ```\n   If `--ff-only` fails, the branch needs rebasing:\n   ```\n   git checkout <branch-name>\n   git rebase main\n   python ~\/.claude\/scripts\/review_scope.py forecast\n   git push --force-with-lease origin <branch-name>\n   python ~\/.claude\/scripts\/review_scope.py status\n   git checkout main\n   git merge <branch-name> --ff-only\n   ```\n\n3. Push main through the shared push step, which gates the published state first \u2014 the merge brings in commits this skill never gated, since they were written and reviewed on the branch \u2014 then pushes, publishes the review bookmark and asks the other machine to pull:\n   ```\n   python ~\/.claude\/skills\/shared\/push.py --caller pr-merge\n   ```\n   Use `python3` on macOS. A refusal from the gate stops the push: fix it in a commit on main rather than publishing a tree that fails the repo's own gate. Report its lines as they stand; the `peer` skill's receipt table explains the `peer-pull:` ones.\n\n### Step 5: Clean up\n\n1. Close the PR (GitHub auto-closes it if the commits match, but verify):\n   ```\n   gh pr view <number> --json state --jq '.state'\n   ```\n   If still open (rare edge case), close it manually:\n   ```\n   gh pr close <number>\n   ```\n\n2. Delete the remote PR branch, bracketed by the bookmark's forecast and status as `~\/.claude\/skills\/shared\/review-bookmark-status.md` describes for any push outside `push.py` (the rebase's force push above too):\n   ```\n   python ~\/.claude\/scripts\/review_scope.py forecast\n   git push origin --delete <branch-name>\n   python ~\/.claude\/scripts\/review_scope.py status\n   ```\n\n3. Delete the local PR branch:\n   ```\n   git branch -d <branch-name>\n   ```\n\n4. Prune stale remote-tracking references (branches deleted on GitHub but\n   still cached locally):\n   ```\n   git remote prune origin\n   ```\n\n5. Delete all other local branches that are fully merged into main:\n   ```\n   git branch --merged main\n   ```\n   Delete any listed branches other than `main` (or `* main`):\n   ```\n   git branch -d <stale-branch>\n   ```\n\n6. If changes were stashed in Step 3, restore them:\n   ```\n   git stash pop\n   ```\n\n7. Report success: show the merged commit(s) on main with signature status:\n   ```\n   git log --oneline --format=\"%h %G? %s\" -5\n   ```\n   Then close the report as `~\/.claude\/skills\/shared\/review-bookmark-status.md` describes.\n","use_cases":["Merge a GitHub PR into the main branch with GPG-signed commits","Ensure that all commits in a PR are verified before merging","Automatically clean up remote and local branches after merging a PR"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/AnotherSava\/claude-code-common\/blob\/1a7f9f9cce53f6946ae1e3a9cc0733f2524a4b93\/claude\/skills\/pr-merge\/SKILL.md","source_commit":"1a7f9f9cce53f6946ae1e3a9cc0733f2524a4b93","license":null,"version":null,"listing_approved_at":"2026-12-01","created_at":"2026-11-30T08:08:21.000000Z","updated_at":"2026-12-01T12:48:20.000000Z","seo_title":"Merge GitHub PR Locally with GPG-Signed Commits","seo_description":"Merge a GitHub pull request into the main branch using a fast-forward merge, ensuring all commits are GPG-signed and preserving the original commit history.","seo_keywords":["GitHub PR merge","GPG-signed commits","fast-forward merge","merge PR locally","clean up branches after merge"]}}