Data report"State of code review 2024" is now liveRead the full report

How to split a pull request into multiple PRs

Greg Foster
Greg Foster
Graphite software engineer


Note

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


In collaborative software projects, large pull requests can be a bottleneck to the review process. Graphite's suite of tools offers a streamlined approach to divide a single large PR into multiple smaller PRs, facilitating faster reviews and improved code quality. This guide will walk you through the process of splitting a PR using Graphite's split and submit commands.

Callout: Smaller PRs tend to be reviewed more quickly and with greater attention to detail, leading to a more robust codebase.

  • Review Efficiency: Shorter PRs are easier and quicker for reviewers to understand.

  • Focused Discussions: Discussions can remain focused on specific changes rather than sprawling across multiple contexts.

  • Faster Integration: Smaller PRs can be merged faster, reducing the risk of merge conflicts.

Before you begin splitting your PR, ensure that you have a clear understanding of how your changes can be logically grouped into separate, self-contained updates.

Graphite's gt split command allows you to create new branches for each group of changes that you want to turn into individual PRs.

  1. Identify Changes: Look at the changes in your current PR and decide how you want to group them.

  2. Run the Split Command: Execute gt split to start the interactive process.

  3. Create New Branches: Graphite will guide you through creating new branches for each set of changes.

Example command:

Terminal
gt split

Once you've split your changes into separate branches, you can use the gt submit command to open new PRs for each branch.

  1. Review Stacks: Use gt stack to review the branches you’ve created.

  2. Submit the Stacks: Execute gt submit to open a PR for each branch in your stack.

  3. Link PRs: Reference each new PR in the original PR to maintain context.

Example command:

Terminal
gt submit

Callout: With gt submit, you can efficiently open multiple PRs simultaneously, a powerful feature for handling complex features or refactorings that span across different parts of the codebase.

Splitting a large PR into multiple smaller ones can significantly enhance the review process. By leveraging Graphite's split and submit commands, developers can easily manage their PRs, resulting in a more efficient and effective development workflow. Adopt these practices to ensure your changes are integrated swiftly and without overwhelming your team.

For a deep dive into each command and more advanced usage, visit Graphite's official documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Learn more

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2