Split a large Pull Request into multiple smaller ones

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

Sometimes a pull request can get quite large, be it by the amount of files added or commits containing too much code to be reviewed, and it's useful to have a way to split it into smaller tasks for your reviewers so that they can focus on specific portions of it or work on it simultaneously, with each reviewer taking care of one of the smaller tasks. This article explores a way to split that large Pull Request into multiple smaller ones using git cherry-pick for the process below:



Environment

Any repository that contains a pull request that has been deemed too large to review, be it because it has too many files, too many conflicts, too much code or any other reason where it might be helpful to split it into smaller tasks.



Solution

To break out a PR in several smaller ones, follow the steps below:

  1. First we want to checkout to the main branch by using the command below:

    git checkout <branch name>
  2. Create a new branch that will be the destination for the new, smaller PR:

    git checkout -b <new_branch>
  3. Use git cherry-pick to separate a subset of commits (eg. regarding some refactoring):

    git cherry-pick <commit_id_1> <commit_id_2>
  4. Create a Pull request

  5. Instruct your reviewers to focus solely on this PR.
  6. After this is merged, update base Pull Requests. There’s less code to check now.

  7. Repeat 2-5 until there’s minimal code on the base pull request (or no code at all).



Last modified on Jan 11, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.