gh-pr-merge
Merge a GitHub pull request
TLDR
Merge the pull request associated with the current branch interactively
Merge the current branch into the specified pull request
Squash and merge a pull request, then delete the branch
Rebase and merge
Enable auto-merge (squash)
Merge with admin privileges (if allowed)
SYNOPSIS
gh pr merge [<number> | <url> | <branch>] [flags]
PARAMETERS
--body <text>
Custom body text for merge commit/PR message
--body-file <file>
Read body from file (use - for stdin)
--delete-branch
Delete local/remote source branch after merge (default if base is default branch)
--merge
Create merge commit (default if base is default)
--rebase
Rebase commits onto base branch
--squash
Squash all commits into single commit
--subject <text>
Custom subject line (prompts if unspecified)
--title <text>
Custom title for resulting commit/PR (prompts if unspecified)
-R, --repo [<HOST/>]<OWNER/REPO>
Operate on specified repository
-w, --web
Open merged PR in browser
DESCRIPTION
The gh pr merge command merges a specified GitHub pull request (PR) on the remote repository. It supports three merge methods: standard merge commit (--merge), squash all commits into one (--squash), or rebase onto the base branch (--rebase). The default method depends on repository settings, typically merge if the base is the default branch.
After merging remotely, it optionally updates the local repository by fetching changes and checking out the base branch. If no PR is specified, it prompts interactively for selection. Custom commit titles, subjects, and bodies can be provided, overriding PR details. Flags allow deleting the source branch post-merge and opening the PR in a browser.
This streamlines CI/CD workflows and team collaboration without browser interaction, ensuring consistent merge strategies. Requires GitHub CLI authentication via gh auth login.
CAVEATS
Requires gh auth login; local updates need clean working directory; merge method must match repo branch protection rules; conflicts prompt manual resolution.
EXAMPLES
gh pr merge (interactive)
gh pr merge 42 --squash --delete-branch
gh pr merge https://github.com/owner/repo/pull/42
EXIT CODES
0: success
1: error (e.g., conflicts, permissions)
HISTORY
Introduced in GitHub CLI v0.5.0 (Feb 2020); evolved with merge method support in v1.0+; aligns with GitHub's web UI changes for squash/rebase defaults.
SEE ALSO
gh(1), gh-pr-checkout(1), gh-pr-view(1), git-merge(1)


