Clone

Create a new repository instance that is a copy of another.

The essential difference between a Centralized Version Control System (CVCS) and a DVCS is the notion of a repository instance.

Just like with a CVCS, when a repository is created for the very first time, we use create. After that, what makes a DVCS different is that we can have multiple instances of that repository. The clone operation is the way those new instances get created.

In a CVCS, the repository exists in one place on a central server. Every piece of software that is used to access the repository includes a network client. See Figure 4.1, “Centralized Version Control”.

Figure 4.1. Centralized Version Control

Centralized Version Control

In contrast, a DVCS allows the repository to exist in more than one place. We can have multiple repository instances. Of course, having more than one instance of the repository means that we will need ways of keeping them synchronized.

In fact, not only does a DVCS allow multiple repository instances, it generally works that way all the time. Most operations interact with a local repository instance, not a network server. The only time networking code gets involved is when the repository instances are being synchronized. Every developer has his own private repository instance. The typical situation ends up looking like Figure 4.2, “Decentralized Version Control”.

Figure 4.2. Decentralized Version Control

Decentralized Version Control

Upon someone’s first exposure to the DVCS concept, it is common to hear them express a measure of alarm because they think that there will not be a central server. But this worry is not necessary. The point of multiple repository instances is not to eliminate the central server. Rather, the point is to get more flexibility. With a CVCS, the central server is the only repository instance, so it must do everything. With a DVCS, we can have repository instances that are dedicated to specific purposes.

In practice, virtually all DVCS teams have a central server. With a CVCS, a central server happens because it is inherent in the centralized model. With a DVCS, a central server happens because of the team’s decision to have one.