| name | merge |
| description | Force-merge an open PR to main (bypassing review requirements), delete the local branch, pull the updated main, and push it to the personal fork remote. Use when the user wants to close out a PR without waiting for review, or run /merge. |
/merge
Force-merge a PR, sync local main, and push to the personal fork.
The user may pass a PR number as an argument (e.g. /merge 4764). If none is given, detect the open PR from the current branch.
Step 1 — Identify the PR and derive fork remote
gh pr view [<number>] --json number,title,headRefName,baseRefName,state
Confirm:
state is OPEN
baseRefName is main
If the PR is already merged or closed: print a message and stop.
Derive the personal fork remote:
GH_USER=$(gh api user -q .login)
FORK_REMOTE=$(git remote -v | grep -i "github.com[/:]${GH_USER}/" | head -1 | awk '{print $1}')
If FORK_REMOTE is empty, print a warning and ask the user to identify their fork remote with git remote -v.
Print the PR title and number, then ask the user to confirm before merging:
"About to force-merge PR #: ''. Confirm? (yes/no)"
Wait for confirmation before continuing.
Step 2 — Force-merge the PR
gh pr merge <number> --squash --admin --delete-branch
--admin: bypasses required review checks and branch protection rules
--squash: squash all commits into one on main
--delete-branch: deletes the remote branch after merge
If the merge fails: print the full error and stop. Do not proceed.
Step 3 — Delete the local branch (if applicable)
Check whether the branch exists locally:
git branch --list <headRefName>
If the branch exists and is not the currently checked-out branch: delete it.
git branch -d <headRefName>
If that fails (branch not fully merged in git's view due to squash): use force:
git branch -D <headRefName>
If we're currently on the feature branch: switch to main first, then delete.
git checkout main
git branch -D <headRefName>
Step 4 — Pull updated main
git fetch origin main
git reset --hard origin/main
After a squash merge, local main always diverges (N commits become 1 on origin), so --ff-only will always fail. reset --hard is correct and safe here — local commits are already represented in the squash on origin.
Step 5 — Push main to personal fork
git push $FORK_REMOTE main --force
Force-push is required after a squash merge because the fork's main still has the pre-squash commits.
Step 6 — Confirm
Print a summary:
"Merged PR #. Local main is up to date with origin/main and pushed to $FORK_REMOTE/main."
Notes
--admin bypasses all branch protection rules including required reviews. Use only when you have confirmed the PR is ready.
- Never force-push to
origin/main (SatcherInstitute). The merge goes through gh pr merge, not a direct push.
- If the PR is on a non-main base branch: stop and warn the user.