gh pr merge
Merge a pull request
What it does
gh pr merge merges a pull request in one of three ways: --merge with a merge commit, --squash as a single commit, --rebase commit by commit on top of the target branch. With no flag gh asks. Which ways are allowed is set in the repository settings.
--delete-branch deletes the branch on GitHub and locally, and switches you to the target branch. --auto turns on auto-merge: the PR merges by itself once the required checks pass, if the repository allows it.
Syntax
gh pr merge <number> --merge|--squash|--rebase
gh pr merge <number> --squash --delete-branch
gh pr merge <number> --auto --squashExamples
Merge pull request 42 as a single commit and delete its branch
gh pr merge 42 --squash --delete-branchsame as:
gh pr merge 42 -s -dpr merge 42— merge the pull request--squash— all the PR's commits as one commit--delete-branch— delete the branch on GitHub and locally
Related commands
- gh pr checks — Check the CI status of a pull request
- git merge — Bring the changes from another branch into the current one
- gh release — Publish a release and list releases