---
title: "Branching in a Sapling Monorepo"
description: "Meta's Sapling monorepo handles branching with two workflows: non-mergeable full-repo branching via sl bookmark for short-lived release branches, and mergeable directory branching via sl subtree for long-lived variants."
url: "https://swe.quest/articles/branching-in-a-sapling-monorepo-3c90aca74756181a"
canonical: "https://engineering.fb.com/2025/10/16/developer-tools/branching-in-a-sapling-monorepo/"
source: "Meta Engineering"
published: "2025-10-16"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["version-control","developer-tools","build-systems"]
---

# Branching in a Sapling Monorepo

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2025-10-16, 7 min read, Case study. Original: [https://engineering.fb.com/2025/10/16/developer-tools/branching-in-a-sapling-monorepo/](https://engineering.fb.com/2025/10/16/developer-tools/branching-in-a-sapling-monorepo/)

## Summary

Meta's Sapling monorepo handles branching with two workflows: non-mergeable full-repo branching via sl bookmark for short-lived release branches, and mergeable directory branching via sl subtree for long-lived variants. Full-repo merges create multi-parent commits that slow sl log and sl blame for everyone. Directory branching instead records copy and merge metadata in linear commits, so Sapling can run scoped three-way merges between directories while the commit graph stays linear. Teams adopt it when CI is expensive, for long-running experimental work, and to unblock Git migrations. Buck2 config modifiers select which branch a build uses, and the main downside is duplicate code-search hits.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Version control](https://swe.quest/tags/version-control.md) (Engineering practices)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)

## Prerequisites

- Git branching and merging
- monorepo concepts ([easy posts on Version control](https://swe.quest/tags/version-control.md?difficulty=easy))
- three-way merge

## Keywords

Sapling, sl subtree, Buck2, monorepo, directory branching, Git

## Related posts

- [Sapling: Source control that’s user-friendly and scalable](https://swe.quest/articles/sapling-source-control-that-s-user-friendly-and-scalable-ac4727ee939b435e.md): Meta Engineering · 2022-11-15 · Easy · 11 min read · Version control, Developer tools, Code review, Scaling, Open source
  Meta has open-sourced the client for Sapling, a Git-compatible source control system built over 10 years that scales to repositories with tens of millions of files, commits and branches.
- [Redesigning source control at Anthropic](https://swe.quest/articles/redesigning-source-control-at-anthropic-ecdbb37746353304.md): Anthropic Engineering · 2026-10-13 · Medium · 17 min read · Version control, System design, Caching, Scaling, AI for coding
  Anthropic replaced git with Scion, an in-house centralized version control system, after its monorepo grew past what git mirrors could serve.
- [Build faster with Buck2: Our open source build system](https://swe.quest/articles/build-faster-with-buck2-our-open-source-build-system-ede49d4bb9123548.md): Meta Engineering · 2023-04-06 · Medium · 7 min read · Build systems, Rust, Open source, Developer productivity
  Buck2 is Meta's from-scratch rewrite of Buck, open sourced with a Rust core and all language rules written in Starlark, and it completes builds about twice as fast as Buck1 internally.
- [Shopify-Made Patterns in Our Rails Apps](https://swe.quest/articles/shopify-made-patterns-in-our-rails-apps-92bda4387ca54f09.md): Shopify Engineering · 2021-07-13 · Easy · 8 min read · Ruby, Developer productivity, Distributed databases, System design, Schema migrations
  Shopify's Rails monolith relies on a set of in-house patterns: the dev CLI for consistent environment setup, a podded architecture that shards the full infrastructure stack by shop, and domain-driven components that share a single database with no database-level foreign keys.
- [How We’re Building Git for Infrastructure](https://swe.quest/articles/how-we-re-building-git-for-infrastructure-bcbbd9a523c86b11.md): Railway · 2023-09-28 · Medium · 9 min read · Configuration management, Testing, PostgreSQL, System design, Deployment
  Railway's Changesets let teams fork an infrastructure environment like a Git branch, record each config or service change as a changeset, and merge it back into the parent environment.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
