Skip to main content

Merging a pull request

Merge pull requests into the upstream branch, choose merge methods, and meet repository requirements like reviews or status checks.

Tool navigation

About pull request merges

Merge a pull request when the proposed changes are ready and any repository requirements are satisfied. You can't merge a draft pull request.

Repository rules or branch protection may require reviews, status checks, or an up-to-date branch before merging. See Informationen zu geschützten Branches.

Als Alternative zu Verzweigungsschutzregeln können Sie Regelsätze erstellen. Rulesets haben einige Vorteile gegenüber Verzweigungsschutzregeln, z. B. Status, und eine bessere Auffindbarkeit, ohne dass ein Administratorzugriff erforderlich ist. Sie können auch mehrere Regelsätze gleichzeitig anwenden. Weitere Informationen finden Sie unter Informationen zu Regelsätzen.

Du kannst einen Pull Request konfigurieren, um automatisch zusammenzuführen, wenn alle Zusammenführungsanforderungen erfüllt sind. Weitere Informationen finden Sie unter Automatically merging a pull request.

If the base branch requires a merge queue, the available merge options differ from those described here. See Merging a pull request with a merge queue.

If the pull request has merge conflicts, or if you want to test changes first, check out the pull request locally.

The repository may automatically delete the head branch after merging. See Automatische Löschung von Branches verwalten.

Hinweis

Wenn du einen Haupt-Branch löschst, nachdem sein Pull Request zusammengeführt wurde, wird GitHub auf offene Pull Requests für das gleiche Repository prüfen, die den gelöschten Branch als ihren Basis-Branch angeben. GitHub aktualisiert solche Pull Requests automatisch, indem es deren Basis-Branch auf den Basis-Branch des zusammengeführten Pull Requests ändert.

Pull requests use the --no-ff option, except squashed or rebased pull requests, which use fast-forward merging.

Sie können eine Pullanforderung mit einem Problem verknüpfen, um anzuzeigen, dass ein Fix ausgeführt wird, und das Problem automatisch schließen, wenn die Pullanforderung zusammengeführt wird. Weitere Informationen finden Sie unter Einen Pull Request zu einem Issue verknüpfen.

If you don't want to merge the changes, you can close the pull request.

Merging a pull request

  1. Klicke unter dem Namen deines Repositorys auf Pull requests.

    Screenshot der Hauptseite eines Repositorys. In der horizontalen Navigationsleiste ist eine Registerkarte mit der Bezeichnung „Pull Requests“ dunkelorange umrandet.

  2. In the "Pull Requests" list, click the pull request you want to merge.

  3. Scroll down to the bottom of the pull request. Depending on the merge options enabled for your repository, choose a merge method:

    Hinweis

    Rebase and merge will always update the committer information and create new commit SHAs. See About pull request merges.

  4. If prompted, type a commit message, or accept the default message.

    Informationen zu den Standardcommitnachrichten für Squashmerges findest du unter Pull request merges.

    Hinweis

    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.

  5. Click Confirm merge, Confirm squash and merge, or Confirm rebase and merge.

  6. Optionally, delete the branch. This keeps the list of branches in your repository tidy.

Hinweis

Weitere Informationen zur GitHub CLI findest du unter Informationen zu GitHub CLI.

To merge a pull request, use the gh pr merge subcommand. Replace pull-request with the number, URL, or head branch of the pull request.

gh pr merge PULL-REQUEST

Follow the interactive prompts to complete the merge. See Pull request merges.

Alternatively, you can use flags to skip the interactive prompts. For example, this command squashes the commits into a single commit with the commit message "my squash commit", merges the squashed commit into the base branch, and then deletes the local and remote branch.

gh pr merge 523 --squash --body "my squash commit" --delete-branch

Further reading