Tech●●●●●Difficulty 1 of 5

How do thousands of programmers edit the same code without chaos?

The trick is never to edit one shared copy: every change is recorded in a history that can be rewound.

▶ Start the story

Programmers avoid chaos by never editing one shared copy. Each person works on their own copy of the code, and a tool called version control records every change as a version, stamped with the date and the person who made it. When two people are done, the tool combines their changes. This combining step is called a , and the shared history it protects is what lets a team stay in step.

The oldest way to keep versions is to copy your files into a new folder with a date on it. It is simple, but it is very error prone: it is easy to forget which folder you are in and overwrite the wrong file. Version control replaces the pile of folders with one history. You can go back to any earlier state of a single file or of the entire project, compare two moments, and see who last touched a line that is now causing trouble.

Two ways to keep versions

Copying folders

  • Easy to start
  • Easy to overwrite the wrong file
  • No record of who changed what

Version control

  • One shared history
  • Go back to any version
  • Every change has a date and an author

The same tool lets people work side by side. A team can keep one line of work for bug fixes only while another line, often called the , carries new features. Each line is a of the history. Sooner or later the lines meet again, and merging is one of the hardest parts of the whole business. If two people changed the same lines, the tool may not be able to decide, and a person has to choose.

You have probably used the idea already. A word processor's undo history, a collaborative web document and the page history of Wikipedia all keep earlier versions you can look at. Lawyers did it long before computers, with contract redlines that show what changed between drafts. Programmers just needed it at a much bigger scale, with many people changing the same files at once.

Quiz me

0/3

  1. 1.Why is copying files into dated folders a poor way to keep versions?
  2. 2.What makes a distributed version control system safer than a centralized one?
  3. 3.When does a merge need a human to step in?

Recap

Version control keeps one rewindable history, so people work on their own copies and merge later instead of overwriting each other.

💡 A trick to remember it · Think of a save-game slot for every change: you can reload any moment, and everyone's saves can be combined.

Surprising fact · Contract redlines used by lawyers are among the earliest forms of version control.

Sources (2)

No source, no claim. Every fact in this lesson (16 claims) cites at least one of these.

  1. [1]Git Book: About Version Control · git-scm.com
  2. [2]Version control · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗