gh pr merge: Usage, Options & Common CI Errors
Merge a pull request - squash, rebase, or merge commit - from the CLI.
gh pr merge merges a pull request using the strategy you pick and can optionally enable auto-merge so the PR lands once checks pass.
What it does
gh pr merge merges a PR via merge commit (--merge), squash (--squash), or rebase (--rebase). --auto enables auto-merge (merges automatically when required checks and reviews pass), and --delete-branch removes the head branch afterward. In CI you must specify the strategy so it does not prompt.
Common usage
# Squash-merge and delete the branch (non-interactive)
gh pr merge 42 --squash --delete-branch
# Enable auto-merge so it lands when checks pass
gh pr merge 42 --auto --squash
# Rebase-merge a specific PR
gh pr merge 42 --rebaseCommon error in CI: prompts for method / not mergeable
gh pr merge hangs asking "What merge method would you like to use?" in a non-TTY, or fails with "Pull request is not mergeable" (conflicts, failing required checks, or a disabled merge method). Fix: always pass one of --merge/--squash/--rebase in CI; for not-mergeable, use --auto so it queues until checks pass, resolve conflicts, and confirm the chosen strategy is enabled in the repo’s branch protection. GH_TOKEN needs repo scope and contents: write / pull-requests: write.
Key options
| Option | Purpose |
|---|---|
| --merge / --squash / --rebase | Merge strategy (required in CI) |
| --auto | Merge automatically when checks pass |
| -d, --delete-branch | Delete the head branch after merge |
| --admin | Use admin privileges to override |