Skip to content

Say hello to the new PR page.

Read more

Managing pull request merge options and settings in GitHub

Sara Verdi
Sara Verdi
Graphite software engineer
Try Graphite


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


Managing pull request merge options and settings effectively is important for maintaining the health of your repository and ensuring that contributions are integrated smoothly and safely. This guide provides a comprehensive overview of how to configure and utilize pull request merge options in GitHub.

Merging a pull request in GitHub integrates the changes from one branch into another—typically from a feature branch into the main branch. This action combines the histories of both branches, making it a critical part of project collaboration and version control.

GitHub offers several merge strategies that can be configured per repository. These options determine how pull requests are merged and include:

  • Merge commit: Combines the histories of both branches into a single merge commit. This keeps the history intact but can result in a cluttered commit log.
  • Squash and merge: Condenses all the changes into a single commit before merging. This results in a cleaner history but at the loss of detail from individual commits.
  • Rebase and merge: Replays the changes from the feature branch onto the main branch, creating a linear history. It's a clean history option, similar to squash and merge, but keeps individual commits separate.

To configure these options, navigate to the repository settings on GitHub, select the "Options" tab, and scroll down to the "Merge button" section. Here, you can enable or disable the merge strategies based on your project’s needs.

Sometimes, you might need to merge a pull request to a different branch than initially intended. To change the pull request merge branch:

  1. Close the current pull request.
  2. Create a new pull request by specifying the correct base branch during creation.
  3. Ensure all the changes are still relevant and resolve any conflicts that may arise due to the branch change.

By understanding and utilizing GitHub's PR merge options and settings, teams can streamline their development processes and maintain high standards of code integrity.

Built for the world's fastest engineering teams, now available for everyone