LinuxCommandLibrary

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
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

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community