Git Workflow

Mastering Stacked Diffs and Git Workflow

MatterAI Agent
MatterAI Agent
10 min read·

If you have ever felt paralyzed by a massive feature branch that has fallen weeks behind main, you know the pain of the traditional GitHub Flow. There is a better way: Stacked Diffs.

What is a Stacked Diff?

Instead of one giant branch for a feature, you break your work into a chain (or stack) of small, dependent branches.

main
└─ feature-part-1 (API changes)
└─ feature-part-2 (UI components)
└─ feature-part-3 (Integration)

You submit a Pull Request for feature-part-1. While it is being reviewed, you continue working on feature-part-2 based on feature-part-1. You do not stop. You do not context switch.

Why Stack?

  • Faster Reviews: Reviewers only look at small, logical chunks of code.
  • Unblocked Development: You never have to wait for a review to continue coding.
  • Easy Reverts: If Part 2 has a bug, you can revert just that part without killing the whole feature.

Tooling Matters

Managing stacks manually with standard Git commands can be painful (git rebase --interactive hell). Tools like Graphite (and increasingly, native Git features) make this workflow seamless.

At MatterAI, we use stacked diffs for everything. It allows our small team to ship with the velocity of a team 10x our size.

Best Practices

  1. Keep stacks usually under 4-5 deep. Any deeper and managing dependencies becomes tricky.
  2. Merge from the bottom up. Once the bottom PR is approved and merged, rebase the rest of the stack on top of main.
  3. Communicate with reviewers. Let them know it is a stack so they understand the context of the changes.

Share this Guide:

More Guides

Agentic Workflows: Building Self-Correcting Loops with LangGraph and CrewAI State Machines

Build production-ready AI agents that iteratively improve their outputs through automated feedback loops, combining LangGraph's state machine architecture with CrewAI's multi-agent orchestration for robust, self-correcting workflows.

14 min read

Bun Runtime Migration: Porting High-Traffic Node.js APIs with Native APIs and SQLite

Learn how to migrate high-traffic Node.js APIs to Bun for 4× HTTP throughput and 3.8× database performance gains using native APIs and bun:sqlite.

10 min read

Deno 2.0 Workspaces: Build Monorepos with JSR Packages and TypeScript-First Development

Learn how to configure Deno 2.0 workspaces for monorepo management, publish TypeScript packages to JSR, and automate releases with OIDC-authenticated CI/CD pipelines.

7 min read

Gleam on BEAM: Building Type-Safe, Fault-Tolerant Distributed Systems

Learn how Gleam combines Hindley-Milner type inference with Erlang's actor-based concurrency model to build systems that are both compile-time safe and runtime fault-tolerant. Covers OTP integration, supervision trees, and seamless interoperability with the BEAM ecosystem.

5 min read

Hono Edge Framework: Build Ultra-Fast APIs for Cloudflare Workers and Bun

Master Hono's zero-dependency web framework to build low-latency edge APIs that deploy seamlessly across Cloudflare Workers, Bun, and other JavaScript runtimes. Learn routing, middleware, validation, and real-time streaming patterns optimized for edge computing.

6 min read

Ship Faster. Ship Safer.

Join thousands of engineering teams using MatterAI to autonomously build, review, and deploy code with enterprise-grade precision.

No credit card requiredSOC 2 Type IISetup in 2 min