Book Deep-Read · Software Engineering at Google · Chapter 16
Software Engineering at Google · Ch 16 · Version Control and Branch Management · Titus Winters · 2020
When a few people edit the same document, sooner or later a folder fills up with "Proposal v5 final", "Proposal v5 final - edits", "Proposal v5 final - Josh's version". Which one is current? Programmers have the same problem, just with millions of times more files and tens of thousands of times more people. The tool that manages it is called version control. This chapter is about how Google's 50,000 engineers share one body of code without it turning into chaos.
Picture an encyclopedia written by tens of thousands of people at once. Version control is a super-librarian who remembers what every page looked like on every day — who changed which sentence, and when — and can flip back to any of it. There is exactly one master copy on the central shelf. Everyone works from it, so nobody has to ask "is your copy the latest?"
Many teams are afraid of damaging the master copy, so each one photocopies the book and writes on its copy for weeks or months, planning to copy everything back in one go. It sounds safe. But by the day they copy it back, other people have changed the master beyond recognition: hundreds of clashes to sort out one by one, and when something breaks, nobody can tell whose section caused it. Some companies even assign one person and a weekly meeting just to decide "whose copy goes back in first this week."
The payoff is that the whole company works at one table: everyone can see what everyone else changed, one change can fix every use across the company, and a new hire simply gets the master copy. The honest cost: putting everyone's code into one book needs very powerful tooling — ordinary tools can't carry that weight — and when different projects have different secrecy rules, a single book gets harder to manage.
Take the choice away: one master copy, one version of everything, small changes straight into the main line — the bigger the team, the more it saves.
Want the real difference between centralized and distributed version control, why long-lived dev branches bank risk, what the One-Version Rule prevents, and whether a monorepo is the only right answer? → Switch to the deep read
You think branches are a safety net that isolates risk; this chapter says that's mostly an illusion. Version control is policy before it is tooling, and the policy that scales is removing choice: one source of truth to commit to, one version of every dependency, and development done in small steps on trunk. Long-lived dev branches just bank merge risk until it all goes off at once.
The first chapter of Part IV, "Tools." It follows Part III's testing, review and deprecation chapters — which are exactly why trunk can stay stable — and sets up Code Search (Ch17), Build Systems (Ch18), Dependency Management (Ch21) and Large-Scale Changes (Ch22), all of which assume "one repo, one version." Real-world counterparts: Git workflow debates, monorepo vs. many repos, trunk-based development vs. feature branches.
The book's thesis is that software engineering is "programming integrated over time," and version control is the engineer's primary tool for managing the interplay between source and time. A filesystem maps filename to contents; a VCS extends that to VCS(filename, time, branch) → contents. The time dimension lets you go back; the branch dimension lets work happen in parallel.
Whether to use a VCS is settled: the author notes that most experienced engineers instinctively use one for any project lasting more than a day or two, even solo. The real question is one level up: how to use it. At Google's scale — roughly 50,000 engineers in one repository, 60,000 to 70,000 commits per working day — any policy on branching, on picking dependencies, or on what counts as "done" that leaves room for choice makes coordination cost grow faster than headcount. The chapter asks which choices should be taken away.
The author starts with cold water: as long as a system can atomically commit a batch of files, all modern VCSs are semantically equivalent, and the rest is user experience. Picking a VCS is like picking a filesystem format — what you put in it and how you use it matter far more. Early RCS used exclusive file locks to prevent simultaneous edits, which jammed once locks became contended. CVS let many people check out at once but lacked atomic commits, so changes could be corrupted or lost. Subversion added true atomicity. All were centralized: one central repository, and every commit goes to the server.
From the mid-2000s, distributed VCS (DVCS) such as Git and Mercurial took over. The core difference is one question: which copies count as a repository — where can you commit? In a DVCS every clone is a full repository; you can commit offline and push to any other repo, and "central" is purely a matter of policy. The author's advice: when in doubt, use Git — there's value in doing what everyone else does.
Google's main repository, though, runs on Piper, an in-house centralized system. The reason is scale. A DVCS by default pulls the whole codebase and its history locally, but the larger the organization, the smaller the fraction of files any one developer touches, so that transfer becomes almost entirely waste. Local files mostly matter for building, and distributed builds (Ch18) handle that better. Google did try to move toward Git and was stopped by the codebase's size and by Hyrum's Law — many scripts assume monotonically increasing commit numbers reflect time order, a hidden dependency that hash-based commit IDs break.
Centralized systems bake the Source of Truth into the design: whatever was most recently committed at trunk is the current version, and your change is "done" once it's recommitted on top of it. A DVCS has no inherent center; in theory patches can flow around uncoordinated, sliding back into the world of "Presentation v5 - final - Josh's version v2." The author's challenge is pointed: without a center, how do you make sure a release includes every feature each developer finished over the past few weeks? Is there any approach, short of everyone signing off, whose human effort grows sublinearly with team size? No — eventually someone keeps a list of which features are ready, and that bookkeeping reinvents a central source of truth. Where does a new hire get a fresh, known-good copy of the code? Same problem.
So well-run DVCS projects declare one branch in one repository to be the source of truth; the spread of GitHub and GitLab is exactly that pattern. Truth can be hierarchical: a Red Hat engineer commits to Red Hat's kernel source of truth, which is pushed upstream periodically, while Linus has his own. As long as there's no uncertainty about where a change should go, the DVCS chaos is avoided.
A key insight of the chapter: every piece of work in progress is equivalent to a branch. Uncommitted local changes are conceptually no different from committed changes on a branch — just harder to find.
Before unit testing was common, "we don't commit to trunk until it's been through a full round of testing on a feature dev branch" made sense; the instability it addressed was real. But the author calls a policy that leans on dev branches for stability "inherently misguided." The same commits must reach trunk eventually; small merges are easier than big ones; an author merging their own changes is easier than batching unrelated changes for later; and if tests fail after a merge, a single engineer's change is easy to pin down while a whole branch's worth is hard to isolate — and harder still to fix.
How do organizations get addicted? They see "merging this long-lived branch reduced stability" and conclude "merges are risky," then slow down and coordinate the symptom. Branches multiply, branches get built on in-flight branches, and some unlucky engineer becomes the full-time Merge Coordinator, with weekly meetings to settle "this week's merge strategy" (a footnote cites an informal Twitter poll suggesting about 25% of engineers have sat through regularly scheduled merge-strategy meetings). All that merging and retesting is pure overhead. The alternative is trunk-based development: lean on tests and CI, keep the build green, disable incomplete features at runtime. Everyone syncs to trunk and commits; no merge meetings, no big merges, and no arguments about which version of a library to use — there can be only one.
Release branches, by contrast, are mostly benign: the problem isn't branch technology, it's usage. A dev branch is expected to merge back to trunk; a release branch is expected to be abandoned eventually, receiving only a few critical fixes cherry-picked from trunk. DORA found release branches practically nonexistent in the highest-performing organizations — if you can release from trunk many times a day, it's easier to fix and redeploy. But if you ship physical devices, knowing exactly which version is "in the field" still matters.
Piper's raw scale isn't what makes Google's collaboration work; a policy does: One Version. It extends "single source of truth" from where you commit to what you depend on: for every dependency in the repository, there must be only one version to choose. Third-party packages have a single version checked in, in the steady state; internal packages may not be forked without renaming — a fork must be safe to link into the same project as the original.
A counterexample shows why. A team finds a bug in common infrastructure like Abseil. Rather than fix it in place, they copy it, patch the bug without renaming the library or its symbols, and tell nearby teams "we've got an improved version here." A few teams start depending on the fork. Now, if any project depends on both the original and the fork, in the best case the build fails; in the worst case two mismatched copies of the same library get linked into one binary and produce baffling runtime bugs. The fork has colored the codebase: every target's transitive dependencies may contain only one of the two, so something as simple as adding a dependency might require running every test in the codebase to be sure no line was crossed.
Java's shading (renaming a library's internal dependencies to hide them) works for functions, but for types passed between packages it fails in theory and in practice — every trick for letting multiple versions coexist in one binary hits that wall. The TL;DR is blunt: the effort spent on such workarounds is entirely lost labor, patching over technical debt. It all condenses into one rule: developers must never have a choice of "what version of this component should I depend upon?" It isn't absolute — upgrading a third-party library may briefly leave two versions checked in, while new users are blocked from the old one and usages migrate incrementally — but for an organization, removing that choice is critical to scaling efficiently.
The first corollary of One Version: dev branches should be minimal and short-lived. Long-lived branches let choice sneak back. An infrastructure team builds a better Widget on a parallel branch; new projects ask "can we depend on your new Widget?" — and because it lives only on another branch, a choice has appeared. The right move is to commit the new Widget to trunk, disabled at runtime, hidden by visibility where possible, or design old and new to coexist in the same binary. Large-scale changes (Ch22) also demand trunk-based development: changing everything on trunk is already a huge job, and an unbounded set of hidden branches to refactor at the same time would be a crushing tax — in a DVCS you might not even be able to find them all.
Of the roughly 1,000 teams working in Google's monorepo, only a couple have such long-lived dev branches (the author's estimate: almost certainly fewer than 10), and the reasons nearly all reduce to compatibility over time: readers and writers of an on-disk data format that must agree across versions, or a promise that an older client still works with a newer server. The author warns that dependency across time is far more costly and complicated than time-invariant code; don't promise it lightly. One more guard is the "build horizon": every production job must be rebuilt and redeployed at least once every six months, capping version skew.
Table 1 · Three uses of branches: same technology, different endings
| Practice | Expected end state | Fits | Honest cost |
|---|---|---|---|
| Trunk-based | small commits to trunk every day | the default; with tests + CI + feature flags | needs a testing culture and a green build; unfinished code lands switched off |
| Release branch | abandoned; receives cherry-picks only | monthly releases, physical devices, knowing what's "in the field" | keep cherry-picks minimal, never plan to remerge; skippable with continuous deployment |
| Long-lived dev branch | merged back to trunk eventually | rare: cross-time compatibility of data formats or APIs | big merges are hard to attribute; coordination grows with branch count; LSCs can't reach it |
Table 2 · Monorepo vs. many repos: the author wants the properties, not the shape
| Dimension | Monorepo | Many repos | Virtual monorepo (VMR) |
|---|---|---|---|
| One Version | harder to violate than to follow | takes discipline; dependencies best unpinned, "at head" | synthesized via a shared trunk and commit order |
| Visibility | everyone sees how others write code | first find which repos matter | depends on the stitching tools |
| Scale | needs a VCS that scales (Git often struggles after a few million commits) | small repos, fast clones | small repos, consistent whole |
| Permissions & compliance | differing needs mean customization and ongoing upkeep | naturally separate access | can isolate secret projects while sharing common code |
| When | all projects share secrecy / legal / privacy / security needs | projects truly independent | differing needs, but you want monorepo properties |
The thread through both tables: choice leads to costs. Let developers choose where to commit or which version to depend on, and you grow merge-strategy meetings, diamond dependencies, lost work and wasted effort.
When an architecture review debates "should we split the repo?" or "should we adopt GitFlow?", this chapter's test is: will it hand developers a version choice again, and will it let merges grow large? In an interview, explaining that "work in progress is a branch," "release branches get abandoned, dev branches get merged," and "forks must be renamed" beats reciting Git commands.
Industry evidence · publicly verifiable
① A VCS extends a filesystem to (filename, time, branch) → contents — the main tool for managing source over time; technology is half of it, policy the other half.
② Any VCS with atomic commits is semantically equivalent; the real centralized-vs-distributed difference is "which copies count as a repo."
③ At scale, full downloads are waste: Google runs the in-house centralized Piper — ~50,000 engineers, 60–70k commits a day.
④ You need a single source of truth (one branch of one repo), or coordination grows faster than headcount; DVCS has to add it by policy.
⑤ Work in progress is a branch; long-lived dev branches bank merge risk. The fix is trunk-based development + tests + CI + runtime flags.
⑥ Release branches are mostly benign: expected to be abandoned, few cherry-picks; continuous deployment can drop them.
⑦ One Version: developers never choose which version to depend on; an unrenamed fork colors the codebase, and shading can't save types.
⑧ Keep long-lived branches for rare cross-time compatibility needs; the build horizon caps production skew at six months.
⑨ A monorepo isn't the only answer — you want its properties, and many repos or a virtual monorepo can deliver them. Choice leads to costs.