How to merge pull requests in GitHub

Sara Verdi
Sara Verdi
Graphite software engineer


Note

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


Merging pull requests (PRs) in GitHub is a key part of the collaborative development process, allowing multiple contributions to be integrated into a single codebase. This guide will explain how to merge PRs in GitHub, including merging into different branches and utilizing Graphite's Merge when ready feature for automatic merging.

  1. Review the pull request:

    • Ensure the PR has been thoroughly reviewed and approved. Check that all checks, such as continuous integration tests, have passed.
  2. Merge the PR:

    • Navigate to the pull request page.
    • Below the PR details, you will find the Merge pull request button. Click on it once all requirements are met.
  3. Choose a merge strategy:

    • GitHub offers several merge strategies:
      • Create a merge commit: Combines the commits from the source branch into the target branch as a single merge commit.
      • Squash and merge: Condenses all commits into one commit before merging.
      • Rebase and merge: Replays the commits from the source branch onto the target branch in a linear history.
  4. Confirm the merge:

    • After selecting your merge strategy, click Confirm merge. Add a commit message if required.
  1. Change the base branch:

    • Before merging, you can change the target branch by clicking Edit next to the base branch at the top of the PR.
    • Select the branch you want to merge into from the dropdown menu.
  2. Follow the standard merge process:

    • Review and merge the PR as described above.
  • Once a pull request is approved, follow the normal merge process. Ensure that all necessary approvals are in place, and no additional changes are needed before merging.
  • If you need to perform a manual merge, such as resolving conflicts or combining multiple branches:
    • Check out the target branch locally using git checkout.
    • Merge the PR branch into the target using git merge <branch-name>.
    • Resolve any conflicts that appear.
    • Commit the changes and push them back to GitHub.
  • To merge changes from another branch into your current branch:
    • Checkout the branch you want to merge changes into.
    • Use git merge <other-branch> to combine the branches.

Graphite offers a convenient feature called Merge when ready, which automates the merging process once all branch protection rules have been met. This is similar to GitHub's automerge but specifically tailored for Graphite's environment.

To enable Merge when ready:

  1. Navigate to the PR page in Graphite.
  2. Toggle on Merge when ready next to the merge button on the PR page.
  3. Graphite will automatically merge the PR once it becomes mergeable and all conditions are met.

This guide has explored several strategies for merging pull requests in GitHub, ensuring you can smoothly integrate team contributions and enhance your project’s development flow, with additional support from Graphite’s Merge when ready feature for automation and ease.

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2