In a pull request, you propose that changes you've made on a head branch should be merged into a base branch. By default, any pull request can be merged at any time, unless the head branch is in conflict with the base branch. However, there may be restrictions on when you can merge a pull request into a specific branch. For example, you may only be able to merge a pull request into the default branch if required status checks are passing. For more information, see "About protected branches."
If the pull request has merge conflicts, or if you'd like to test the changes before merging, you can check out the pull request locally and merge it using the command line.
You can't merge a draft pull request. For more information about draft pull requests, see "About pull requests."
You can have head branches automatically deleted after pull requests are merged in your repository. For more information, see "Managing the automatic deletion of branches."
If you decide you don't want the changes in a topic branch to be merged to the upstream branch, you can close the pull request without merging.
Tip: You can also merge a pull request using the GitHub CLI. For more information, see "
gh pr merge" in the GitHub CLI documentation.
Under your repository name, click Pull requests.
In the "Pull Requests" list, click the pull request you'd like to merge.
Depending on the merge options enabled for your repository, you can:
- Merge all of the commits into the base branch by clicking Merge pull request. If the Merge pull request option is not shown, then click the merge drop down menu and select Create a merge commit.
- Squash the commits into one commit by clicking the merge drop down menu, selecting Squash and merge and then clicking the Squash and merge button.
- Rebase the commits individually onto the base branch by clicking the merge drop down menu, selecting Rebase and merge and then clicking the Rebase and merge button.
Note: Rebase and merge will always update the committer information and create new commit SHAs. For more information, see "About pull request merges."
If prompted, type a commit message, or accept the default message.
For information about the default commit messages for squash merges, see "About pull request merges."
Note: The email selector is not available for rebase merges, which do not create a merge commit, or for squash merges, which credit the user who created the pull request as the author of the squashed commit.
- Click Confirm merge, Confirm squash and merge, or Confirm rebase and merge.
- Optionally, delete the branch. This keeps the list of branches in your repository tidy.
The repository may be configured so that the head branch for a pull request is automatically deleted when you merge a pull request. For more information, see "Managing the automatic deletion of branches."
You can link a pull request to an issue to show that a fix is in progress and to automatically close the issue when someone merges the pull request. For more information, see "Linking a pull request to an issue."