// THE CANONICAL GIT STACK ENCYCLOPEDIA

Master The Git Stack

The authoritative open-source reference for Stacked Pull Requests and the internal Git Stash Stack. Stop letting 2,000-line mega-PRs bottleneck your engineering team.

Meaning 1 • Team Workflow

Stacked Pull Requests (Stacked Diffs)

A methodology popularized at Meta, Google, and Stripe where engineers decompose large features into a sequential chain of small, dependent, atomic reviewable branches.

Trunk-Based Atomic Reviews Graphite Sapling
Meaning 2 • Git Data Structure

The Git Stash Stack

Git’s native LIFO (Last-In, First-Out) commit stack. Manages uncommitted working tree states, staged indexes, and temporary context switches across branches.

stash@{n} LIFO Array Index Commits git fsck Rescue
Concept Deep-Dive #1

The Stacked Pull Request Workflow

Why engineering velocity at scale requires moving away from monolithic branches.

× The Traditional "Mega-PR" Anti-Pattern

A developer creates a branch called feature/user-profiles and codes for two weeks: schema updates, API endpoints, payment webhooks, and React UI components.

  • Review Fatigue: Teammates see +1,800 lines changed and delay reviewing it for days.
  • Superficial Approvals: "LGTM!" without catching subtle logic flaws in the database layer.
  • Merge Conflict Hell: The longer the branch stays open, the more drift accumulates against main.

✓ The Git Stack Solution

The developer splits the feature into a sequential Stack of 3 atomic branches:

  • PR 1 (Bottom): Schema migration (+60 lines) → Reviewed & approved in 20 minutes.
  • PR 2 (Middle): API route (branched off PR 1) → Developed without waiting for merge.
  • PR 3 (Top): Frontend UI (branched off PR 2) → Clean separation of concerns.
Interactive Playground

Live Branch Stack Simulator

Experience how branch stacking and cascade rebasing work in real-time.

$ gt create -> gt submit
Concept Deep-Dive #2

The Git Stash Stack & Internals

How Git’s internal Last-In, First-Out stack works behind the scenes.

Under the Hood: .git/refs/stash

When you execute git stash push, Git does not save a plain text diff file. Instead, it generates a special commit object with multiple parents in your object database:

COMMIT 1
Index State

Captures everything currently in your staging area (files added via git add).

COMMIT 2
Working Tree State

Captures all unstaged file modifications across your directory.

COMMIT 3 (with -u)
Untracked Files

Stores brand-new files not yet committed into Git history.

Ecosystem Directory

2026 Git Stacking Tools Matrix

Unbiased evaluation of modern CLI clients that automate branch stacks.

Graphite ★ 5.8k

The leading GitHub-native stacking client. CLI tool that creates, syncs, and submits stacks with automated interactive navigation tables in PR bodies.

gt create → gt submit → gt restack
License: Free CLI Website →
Sapling ★ 7.2k

Meta's battle-tested source control client. Operates completely branchless with stacked smartlog trees and virtual file system cloning for massive repos.

sl commit → sl pr → sl goto
License: GPL-2.0 (Meta OSS) Website →
git-branchless ★ 4.1k

High-velocity monorepo workflow written in Rust. Pure Git extension that brings branchless commit graphs and undo/redo time travel to native Git.

git smartlog → git restack → git undo
License: MIT / Apache 2.0 Website →
git-town ★ 3.4k

Automates trunk-based development, branch stacking, rebasing against main, and cleanup of merged branches in one command.

git town append → git town sync
License: MIT Website →
Aviator ★ 1.2k

Enterprise merge queue combined with stacked PR automation. Features parallel CI testing, auto-rebase cascading, and queue lane prioritization.

av pr create → av stack sync
License: Commercial / Free Tier Website →
Practical Manual

The Git Stack Command Playbook

Production-grade command sequences for stacking, restacking, and stash rescue.

1. Building a 3-Branch Stack in Native Git

Stacked PRs

How to construct dependent branches (Schema → API → UI) without any third-party CLI tools.

# 1. Base branch for database migration
git checkout -b feature/db-schema main
git commit -m "feat(db): create user profile schema"
git push -u origin feature/db-schema

# 2. Middle branch stacked on schema
git checkout -b feature/api-routes feature/db-schema
git commit -m "feat(api): profile REST endpoints"
git push -u origin feature/api-routes

# 3. Top branch stacked on API
git checkout -b feature/ui-screen feature/api-routes
git commit -m "feat(ui): profile settings modal"
git push -u origin feature/ui-screen

2. Cascading Restack After Editing a Parent Branch

Rebase Cascading

When you modify PR #1 based on code review, use git rebase --onto to re-link downstream children cleanly.

# 1. Update the parent branch
git checkout feature/db-schema
git commit --amend --no-edit
git push -f origin feature/db-schema

# 2. Rebase child onto updated parent
git checkout feature/api-routes
git rebase --onto feature/db-schema HEAD@{1} feature/api-routes
git push -f origin feature/api-routes

# 3. Rebase top grandchild onto updated child
git checkout feature/ui-screen
git rebase --onto feature/api-routes HEAD@{1} feature/ui-screen
git push -f origin feature/ui-screen

3. Rescuing an Accidental Dropped Stash

Stash Recovery

If you ran git stash drop by mistake, recover the orphaned commit object before garbage collection runs.

# 1. Locate all unreachable commits
git fsck --lost-found | grep commit

# 2. Inspect the commit message and diff to verify your code
git show <COMMIT_SHA>

# 3. Restore the commit into your working branch
git merge <COMMIT_SHA>
# or
git cherry-pick <COMMIT_SHA>

4. Stashing Untracked Files with Named Identifiers

Stash Hygiene

Avoid losing context in a pile of anonymous WIP on main stashes.

# Push with descriptive name including newly created files (-u)
git stash push -u -m "wip: checkout form stripe webhook logic"

# Preview the patch diff without modifying working directory
git stash show -p stash@{0}

# Apply specific stash by index without removing it from stack
git stash apply stash@{0}

# Pop to apply and delete from stack
git stash pop stash@{0}
Live Telemetry

Daily Git Stack Radar

Automated daily telemetry of open-source stack tooling, synced via VPS autopilot.

LIVE CRON SYNC ACTIVE
Autopilot Sync: Active
Tool & Repository Stars Issues Last Commit Link
Sapling (facebook/sapling) ★ 7,240 381 open Oct 30, 2026 Inspect GitHub →
git-branchless (arxanas/git-branchless) ★ 4,140 95 open Oct 24, 2026 Inspect GitHub →
git-town (git-town/git-town) ★ 3,400 54 open Oct 23, 2026 Inspect GitHub →