LinuxCommandLibrary

gh-pr-merge

TLDR

Merge current PR

$ gh pr merge
copy
Merge with squash
$ gh pr merge --squash
copy
Merge with rebase
$ gh pr merge --rebase
copy
Delete branch after merge
$ gh pr merge --delete-branch
copy
Auto-merge when ready
$ gh pr merge --auto
copy

SYNOPSIS

gh pr merge [pr-number] [options]

DESCRIPTION

gh pr merge merges pull requests using GitHub's merge API. It supports all merge strategies: merge commits, squash merging, and rebasing. The command can wait for required checks and approvals.
Auto-merge enables setting a PR to merge automatically once all requirements are satisfied, useful for approved PRs waiting on CI. The delete-branch option cleans up after merging.
gh pr merge completes the pull request workflow from the command line.

PARAMETERS

PR-NUMBER

Pull request number (defaults to current branch).
--merge
Use merge commit (default).
--squash
Squash commits into one.
--rebase
Rebase commits onto base branch.
--delete-branch
Delete branch after merge.
--auto
Enable auto-merge when requirements met.
--admin
Merge with admin privileges.
--body TEXT
Custom merge commit message.
--help
Display help information.

CAVEATS

Branch protection rules may prevent merging. Auto-merge requires repository feature enabled. Admin flag overrides protections.

HISTORY

gh pr merge is part of the GitHub CLI, implementing all merge strategies available through GitHub's web interface.

SEE ALSO

Copied to clipboard