Devtov Online — Version Control Systems Explained | devtov.online

Commits, branches and merges

Devtov Online — Version Control Systems Explained | devtov.online

A version control system records every change made to a set of files, keeps a dated history of those changes, and lets several people work on the same code without overwriting each other. Commits write changes into the repository; branches split the history so one line of work can fix bugs while another adds features; merges bring the lines back together.

1972SCCS appears for the OS/360 mainframe.1982Revision Control System (RCS) is dated to this year.1986CVS adds network and concurrent features; rewritten in C in 1990.2000Subversion is released.2005Git, Mercurial and GNU Bazaar all appear.
A commit moves changes from the working copy into the repository; a checkout pulls them back out.

01

The repository and the working copy

A commit writes working-copy changes into the repository, and a checkout retrieves them. Every routine save-and-load cycle in version control is one of these two movements.

02

Branches that split the line

Branches let one line of work fix bugs while another adds features. The split is cheap to create and the two lines can grow independently until a merge rejoins them.

03

A graph, not a tree

Merges create extra edges, so the history of a project forms a graph rather than a tree. Renames, splits and merges add identity problems that revision tracking must resolve.

What does a version control system actually do?

It stores every revision of a project's files so changes can be compared, restored and, with some types of files, merged.

A commit writes working-copy changes into the repository. The working copy is the set of files on disk where edits happen; the repository is the stored history. A checkout retrieves those changes back into a working copy, which is how a developer loads someone else's work or returns to an earlier state.

Because revisions can be compared, a developer can see exactly which lines changed between two points in time. Revisions can also be restored, so a bad edit can be undone by pulling an older revision forward. With some types of files — plain text, for instance — two sets of changes can even be merged automatically.

The system also resolves identity problems: renaming, splitting or merging files creates ambiguity about which file a revision belongs to, and revision tracking has to resolve that ambiguity so the history stays readable.

  • Commit: writes working-copy changes into the repository.
  • Checkout: retrieves stored changes back into a working copy.
  • Compare: shows which lines differ between two revisions.
  • Restore: brings an older revision back into the working copy.
  • Merge: combines two sets of changes where the file type allows it.

The systems, one card at a time

1972

SCCS on the mainframe

The Source Code Control System appeared in 1972 for the OS/360 mainframe — the first system in this table.

1982

RCS

Revision Control System dates to 1982 and established the local, file-per-project pattern that later tools built on.

1986 / 1990

CVS goes networked, then C

CVS added network and concurrent features from 1986 and was rewritten in C in 1990, making shared repositories practical.

2000

Subversion

Subversion was released in 2000, improving on CVS with atomic commits and better handling of renames and directory moves.

2005

Git, Mercurial, Bazaar

Git, Mercurial and GNU Bazaar all appeared in 2005, moving the model from a central server to copies of the full history on every machine.

Identity

Renames and splits

Renaming, splitting or merging files creates identity problems that revision tracking must resolve before comparisons and restores can be trusted.

Because merges create extra edges, the history of a project forms a graph rather than a tree.

Dated systems at a glance

Version control systems with the year each appeared
SystemYearWhat changed
SCCS1972First system, for the OS/360 mainframe
RCS1982Local revision control for single files
CVS1986Network and concurrent features added
CVS in C1990Rewritten in C
Subversion2000Released as a successor to CVS
Git2005Distributed model, full history per clone
Mercurial2005Distributed system released the same year
Bazaar2005GNU Bazaar appeared in 2005
Version control systems with the year each appeared

Questions readers actually ask

What is the difference between a commit and a checkout?
A commit writes working-copy changes into the repository, while a checkout retrieves them. The first direction saves, the second loads.
Do I need branches if I work alone?
Branches let one line of work fix bugs while another adds features, which applies to solo work too. Without a branch, a fix and a feature share one line and cannot be reviewed or reverted separately.
Why does my history show two parents for one revision?
A merge rejoins two lines, so the merged revision has two parents — that is the extra edge that makes history a graph rather than a tree.
What happens if I rename a file on a branch?
Renaming creates identity problems that revision tracking must resolve. If the system tracks the rename, the merge is clean; if it treats the rename as delete-plus-add, the merge produces conflicts.

Sources

The dates and system descriptions listed above are drawn from the documented release history of each system.

What does a versioncontrol systemWhy does historyform a graph, notHow do commits andbranches work inWhich systems existand when did theyHow do you tell atrunk, a branchWhat goes wrongwhen you rename or
A map of this guide's sections