gh-pr-merge

Merge pull requests using GitHub API

TLDR

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

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 before proceeding.Auto-merge (--auto) sets a PR to merge automatically once all requirements are satisfied, useful for approved PRs waiting on CI. The --delete-branch option cleans up feature branches after merging.

PARAMETERS

PR-NUMBER

Pull request number (defaults to current branch).
--merge
Create a standard merge commit.
--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.

INSTALL

sudo apt install gh
sudo dnf install gh
sudo pacman -S github-cli
sudo apk add github-cli
sudo zypper install gh
brew install gh
nix profile install nixpkgs#gh

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

gh-pr(1), gh-pr-checks(1), git-merge(1)

RESOURCES

Documentation · Source code