LogoLogo
HomeAbout usSign up
  • Introduction
  • AttentionSet
    • AttentionSet Best Practices
    • How to View AttentionSet for Others
    • How to Manually Change Attention
    • AttentionSet Chrome extension
    • Attention reasons
    • AttentionSet Slack Home Page
  • Releases
    • Getting Started with Releases
    • Concepts for Releases
      • Terminology for Releases
      • Two-step delivery
      • Rollbacks
      • Cherry-picks
      • Dogfood, Canary and Rollout
      • Release notes
    • How-to Guides for Releases
      • How to Create a Release Project
      • How to Configure Environments
      • How to Create a Scheduled Release
      • Create Custom Workflow Parameters
      • How to Manage Cherry-Picks
      • How to Resolve a Cherry-Pick Failure
      • Working with your CI / CD
        • GitHub Actions workflow
        • Buildkite workflow
    • API Reference for Releases
  • FlexReview
    • Getting Started with FlexReview
    • How to Onboard a Large Org
    • Concepts for FlexReview
      • Read-Only Mode in FlexReview
      • Recursive Ownership in FlexReview
      • Reviewer suggestion and assignment
      • FlexReview Teams and SLO Management
      • Validation in FlexReview
    • How-to Guides for FlexReview
      • How to Get a Reviewer Suggestion
      • How to Exclude Reviewers
      • How to Set Up Team Rules
      • Whitelist Teams for Review Assignment
      • Troubleshoot Reviewer Assignment
      • PagerDuty Integration for Reviewers
      • How to Set Up FlexReview Validation
      • Recommended Slack Notification Settings
      • How to Exclude OOO Reviewers
    • FlexReview Reference
      • Configuration
      • Slash commands
      • Expert scoring algorithms
      • Slack Notifications
      • Out of Office User Exclusion
    • FlexReview Roadmap
  • MergeQueue
    • Getting Started with MergeQueue
    • Merge Rules
    • How-to Guides for MergeQueue
      • How to Configure Base Branches
      • How to Customize Required Checks
      • How to Set Up Fast-Forwarding
      • How to Set Up Pre-Queue Conditions
      • How to Queue / Dequeue via API
      • Pause / Unpause Queues via API
      • Slash Commands Using GitHub Comments
      • How to Customize Sticky Comments
      • Require an Aviator Status Check
      • Backport a PR
      • How to Configure ChangeSets
      • Custom Integrations
        • GitHub Integration
      • How to Create Personal Access Tokens
      • How to Set Up SAML Configuration
        • Microsoft Active Directory
      • How to Merge Stacked PRs
      • How to Block Pull Request Mergeing with Slash Commands
    • Concepts for MergeQueue
      • Queue Modes
      • Pull Request Lifecycle
      • Analytics
      • Parallel Mode
      • CI Status Requirements
      • MQ Created Branches
      • Batching
      • Managing flaky tests
      • Fast-forwarding
      • Pre-Queue Conditions
      • Sticky Comments
      • Backporting
      • Paused Queues
      • Affected Targets
        • Directory-Based Affected Targets
        • nx based affected targets
        • GitHub Actions based Affected Targets
      • ChangeSets
        • Global CI Validation
        • ChangeSets FAQs
      • Priority Merges
        • Instant Merges
      • Merge Rules Audit Trail
      • Timeline
      • Ready Hook
      • Reduce Queue Failures From Staleness
    • MergeQueue References
      • Configuration Schema
      • Configuration Reference MergeQueue
      • GitHub Slash Commands
      • Status Codes
  • Stacked PRs CLI
    • Quickstart for Stacked PRs CLI
    • CLI Installation
    • How-to Guides for Stacked PRs CLI
      • How to Create Stacked PRs in CLI
      • How to Navigate & Modify Stacked PRs
      • Add Commits in the Stack
      • How Split a Commit in CLI
      • How to Split and Fold Pull Requests
      • How to Rename a Branch in CLI
      • How to Adopt a Branch in CLI
      • Orphan a Branch with Aviator CLI
      • How to Do Git Subcommand Aliasing
      • How to Create an Access Token
      • How to Set Up Auto Completion in CLI
      • How to Use Editor Plugins in CLI
    • Concepts for StackedPRs CLI
    • How to Rebase and Sync with GitHub
    • Configuration for StackedPRs CLI
    • Stacked PRs FAQs and Troubleshooting
      • Working with Aviator CLI
      • Default Branch Update Master to Main
    • Manpages for Stacked PRs CLI
      • av(1)
      • av-adopt Command Guide
      • av-auth-status(1) in CLI
      • av-stack-branch(1) in CLI
      • av-commit-create(1) in CL
      • av-stack-diff(1) in CLI
      • av-fetch(1) in CLI
      • av-git-interaction Command Guide
      • av-init(1) in CLI
      • av-stack-next(1) in CLI
      • av-orphan Command Guide
      • av-pr-status(1) in CLI
      • av-pr-create(1) in CLI
      • av-stack-prev(1) in CLI
      • av-stack-reorder(1) in CLI
      • av-reparent Command Guide
      • av-restack Command Guide
      • av-commit-split(1) in CLI
      • av-switch Command Guide
      • av-stack-sync(1) in CLI
      • av-stack-tidy(1) in CLI
      • av-stack-tree(1) in CLI
    • Aviator CLI Major Releases
      • Aviator CLI v0.1.0 Release Notes
  • Aviator's Chrome Extension
  • Pilot Automated Actions
    • Scheduled Events
    • JavaScript Execution
    • Pilot Automated Actions Reference
      • GitHub Reference
      • MergeQueue Reference
      • Slack Reference
  • API and Integrations
    • Slack Integration Guide
    • GraphQL API Quickstart
    • Prometheus Metrics Setup for GCP
    • Reference
      • JSON API
      • GraphQL
      • Webhooks
      • Monitoring Metrics
  • Manage
    • Access Management
    • GitHub App Permissions
    • Security
      • Aviator Agents Data Usage & Retention Policy
    • On-Premise Installation
      • GitHub App for On-Prem
      • GitHub OAuth for On-Prem
      • Use Helm Instructions
      • Use Docker Compose Instructions
      • Prometheus endpoint
      • Slack Integration for On-Premise
      • Google SSO Login for On-Prem
    • FAQs
      • Troubleshooting GitHub app connection
      • MergeQueue FAQs
      • Billing FAQs
Powered by GitBook
On this page
  • Overall Workflow
  • Setup
  • Split the branch
  • Fold the branches

Was this helpful?

  1. Stacked PRs CLI
  2. How-to Guides for Stacked PRs CLI

How to Split and Fold Pull Requests

Learn how to split and fold pull requests in our how-to guide. It's helpful when you accidentally create a large pull request and must split it for code review.

PreviousHow Split a Commit in CLINextHow to Rename a Branch in CLI

Last updated 5 months ago

Was this helpful?

Occasionally you might accidentally create a large pull request. In order to do an effective code review, you want to split such large PRs. Aviator CLI allows you to split them.

Overall Workflow

In Aviator CLI, one branch corresponds to one PR. To split a large pull request, we take two steps:

  1. Split a large commit into multiple commits.

  2. Reorder and split commits into stacked branches.

By using , you can split a large commit into pieces. The guide below walks you through how to reorder and split those commits.

Setup

Let's use repository as an example.

$ git clone https://github.com/octocat/hello-world hello-world
$ cd hello-world
$ av init
$ touch myfile
$ git add myfile

Then, create one branch.

$ av branch stack-1
$ echo 1a >> myfile
$ git commit -m 1a myfile
$ echo 1b >> myfile
$ git commit -m 1b myfile
$ echo 2a >> myfile
$ git commit -m 2a myfile
$ echo 2b >> myfile
$ git commit -m 2b myfile

This creates 4 commits.

Split the branch

Run av reorder. It opens an editor and shows the initial reordering plan.

stack-branch stack-1 --trunk master@7fd1a60b01f91b314f59955a4e4d4e80d8edf11d
pick 7329d18  # 1a
pick a89140c  # 1b
pick 4702825  # 2a
pick e875223  # 2b

Currently, we have a branch stack-1, branched off from master. We will move the commit 2a and 2b into stack-2. To do this, change the plan into following:

stack-branch stack-1 --trunk master@7fd1a60b01f91b314f59955a4e4d4e80d8edf11d
pick 7329d18  # 1a
pick a89140c  # 1b

stack-branch stack-2 --parent stack-1
pick 4702825  # 2a
pick e875223  # 2b

Save and close the editor. Aviator CLI picks up the commit 1a and 1b on stack-1 and picks up the commit 2a and 2b on stack-2.

Starting branch stack-1 at 7fd1a60
  - applied commit 7329d18 without conflict (HEAD is now at 7329d18)
  - applied commit a89140c without conflict (HEAD is now at a89140c)
Starting branch stack-2 at a89140c
  - applied commit 4702825 without conflict (HEAD is now at 4702825)
  - applied commit e875223 without conflict (HEAD is now at e875223)
Reorder complete!

The stack was reordered successfully.

This creates a commit graph like this.

Fold the branches

The opposite operation is possible as well. Run av reorder again.

stack-branch stack-1 --trunk master@7fd1a60b01f91b314f59955a4e4d4e80d8edf11d
pick 7329d18  # 1a
pick a89140c  # 1b

stack-branch stack-2 --parent stack-1
pick 4702825  # 2a
pick e875223  # 2b

Remove stack-branch stack-2 --parent stack-1, save, and exit.

WARNING: the following branches were removed from the reorder:
  - stack-2

What would you like to do?
    [a] Abort the reorder
    [d] Delete the branches
    [e] Edit the reorder plan
    [o] Orphan the branches (the Git branch will continue to exist but will not
        be tracked by av).

[a/d/e/o]: d
Starting branch stack-1 at 7fd1a60
  - applied commit 7329d18 without conflict (HEAD is now at 7329d18)
  - applied commit a89140c without conflict (HEAD is now at a89140c)
  - applied commit 4702825 without conflict (HEAD is now at 4702825)
  - applied commit e875223 without conflict (HEAD is now at e875223)
Deleted branch stack-2.
Reorder complete!

The stack was reordered successfully.

This time, since we removed the branch stack-2 from the plan, it prompts you what to do with that branch. Since we do not need it anymore, we choose "Delete the branches".

The branch stack-1 now has the commit 1a through 2b.

Split a Commit feature
Hello-World