Skip to main content
Break down large features into smaller, dependent branches that build on top of each other. Stacked diffs make code review easier and allow for incremental merging.

Overview

The wit stack command helps you manage chains of dependent branches (stacks) that build on each other. This workflow is popular at companies like Meta and Google.

Why Stacked Diffs?

Traditional branching creates large, hard-to-review PRs. Stacked diffs let you:
  • Break down features into reviewable chunks
  • Get faster reviews with smaller PRs
  • Merge incrementally as each piece is approved
  • Keep working while waiting for reviews

Commands

create

Start a new stack from the current branch.

Examples

Output


push

Create a new branch on top of the stack.
If no name is provided, a name is auto-generated based on the stack name.

pop

Remove the top branch from the stack (keeps the branch itself).

list

Show all stacks in the repository.

Example Output


show

Display a visual representation of the current stack.

Example Output


sync

Rebase the entire stack when the base branch changes.
This rebases each branch in the stack onto its parent, ensuring the entire chain is up-to-date.

Example Output

Handling Conflicts

If conflicts occur during sync:

submit

Push all stack branches to the remote for review.

delete

Delete a stack (keeps the branches).

up

Move to the child branch (up the stack).

down

Move to the parent branch (down the stack).

goto

Jump to a specific branch in the stack.

reorder

Reorder branches in the stack.
After reordering, run wit stack sync to rebase branches to the new order.

Complete Workflow Example

Here’s a complete stacked diffs workflow:

Best Practices

Keep Branches Small

Each branch should be a logical, reviewable unit:
  • 200-400 lines of changes
  • Single concern or feature aspect
  • Self-contained tests if applicable

Name Branches Descriptively

Use meaningful names that describe the change:

Sync Regularly

Run wit stack sync frequently to:
  • Keep your stack up-to-date with main
  • Catch conflicts early
  • Make merging easier

Review in Order

PRs in a stack should be reviewed and merged in order (bottom to top) to maintain dependencies.