LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

gh-pr-merge

Merge pull requests using GitHub API

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 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
copy
sudo dnf install gh
copy
sudo pacman -S github-cli
copy
sudo apk add github-cli
copy
sudo zypper install gh
copy
brew install gh
copy
nix profile install nixpkgs#gh
copy

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

RESOURCES

Copied to clipboard
Kai