BOOKS DEEP-READ · CONTINUOUS DELIVERY · CH 14

Advanced Version Control

Continuous Delivery · Ch 14 · Jez Humble & David Farley · 2010

中文 →

What is this chapter about?

A piece of software has dozens or hundreds of people editing the same pile of files, and at the end it all has to add up to one thing you can ship. The tool that keeps this from descending into chaos is called version control. This chapter isn't about how to drive the tool. It asks the one question no team escapes: should everyone take their own copy, work apart, and combine at the end — or should everyone fold their work back into the shared copy every day?

Start with something strange

Two colleagues work apart for two months. On merge day the tool cheerfully reports no conflicts — not a single line needs a human. Then the code runs, and it's broken.

Why? The tool only checks whether two people edited the same line of text. One of them quietly changed how a shared routine calculates something; the other wrote new logic elsewhere that was counting on the old behaviour. Different files, different lines — of course the tool saw no conflict. But what came out is already wrong. "The merge went smoothly" and "the merge is correct" are two different claims.

Why the old world was hard

The pain of working apart isn't spread evenly over time — it snowballs. Work apart for a week and the two of you probably touched different corners. Work apart for two months and you've both renovated the same set of files; combining goes from "a few spots arguing" to "nobody can say whether the result is still right."

Worse, it makes people timid. You know some piece of code should be tidied up — but tidying it means everyone else suffers extra on merge day. So nobody touches it, and the bad parts keep piling up.

This chapter's answer: don't work apart

The book is blunt: everyone folds their changes back into the shared copy every single day, so the window in which the two sides can drift is too short for trouble to grow in it.

"But my work isn't finished — won't it leak out?" The whole value of this chapter is in answering that. It offers three moves. Leave the door shut: the code for a new feature can go in early, it just has no button, menu or address that reaches it yet; you open the door when it's done. Break a big change into a string of small ones, each of them complete and shippable on its own. Put up scaffolding: when you need to swap out an old part that everything depends on, first insert an adapter in the middle, hang the old and new parts off it at the same time, move users across a bit at a time, then take down both the old part and the adapter. Renovate one room at a time instead of moving house.

How to choose

Being apart for a few hours, even a day, is fine. Being apart for weeks or months is the actual enemy. Which is why today's habit of "open a branch, merge it back the same day" is on the same side as this book, not against it.

The price has to be said out loud too: those switches and that scaffolding are themselves debt. They must be torn out once they've done their job — otherwise, the day someone trips over a switch that should have been deleted years ago, the damage is worse than working apart ever was.

Remember this one line

Working apart looks like separating risk. It is actually saving risk up and paying for it all at once. The longer you stay apart, the more dangerous rejoining becomes — and the danger often arrives without an alarm. So: merge back daily, and solve the real problem ("my work isn't finished") with closed doors and scaffolding instead of distance.

Want the mechanisms, the bill for each branching model, and the diagrams? → Switch to the deep read