A distributed version control system, as its name suggests, is a version control system that is distributed across machines, networks, and regions.
Unlike centralized VCS, distributed VCSs enable anyone to work on the repository without being provisioned by a central server.
Note in this book, i use the distributed version control system called git. you can explore other options such as tFs as well, as most of the concepts are similar. to a single user, the differences are not obvious. you will only feel the differences in these two version control systems when you work in a team environment.
With this design, the users maintain a copy of the repository on their own machine. There is no original repository, just remote repositories. This concept is illustrated in Figure 4-3.
Each user can have their own copy of the repository. There is no direct link linking to the “original” repository. Each user is free to make their own changes and start the project from there. This is a concept called forking. In forking, we create a clone of the repository and work on the clone separately. Note that the original and the clone are two different repositories, but since they have a similar history tree, we can merge them later if we approve the contributions. Every repository can be a source of truth, and every repository can be a temporary repository for a new feature addition or for testing.
The common traits of distributed VCSs are as follows:
• The code base and its copies are distributed across multiple machines and networks. There is no central repository to share or track the changes with.
• A distributed version control system also supports user Figure 4-3.
Distributed version control systems use separate copies
of the repository. Each copy can act as the source of truth. Each user is
free to work on their own repository separately
• Policies and control are managed per repository.
• Since each repository can be a source of truth, every repository needs to manage its own set of policies.
Distributed VCSs specialize in the management of source code in a distributed environment in so many ways. Let’s look at an example of Git2 version control. You can get a copy of Git version control for your platform from https://git-scm.com. Install it and then you can proceed with the next steps in this chapter. Git version control supports user accounts. If you are new to the Git environment, this is the first thing you need to perform in order to finish setting up Git version control.
$ git config --global user.name "John Doe"
$ git config --global user.email "[email protected]"
This step configures the Git version control to share the author details with each commit. Git also takes security measures and provides support for SSH. SSH is secure shell access that uses public/private certificates to authenticate and secure the traffic. This protects the data that you are transferring to and from the remote3 repositories.
In a distributed environment, you are not required to wait for other users to finish their work. You can work on your projects on your own machine, independently. This applies to everyone on the network as well as off the network. Git keeps a history of the changes that are made on each repository and on the clone of the repository. Each user (along with their user details) then commits their changes to the remote repositories to publish them.
2 Git is a free and open source distributed version control system developed by Linus Torvalds and is used extensively in the development of and for the packages developed on the Linux operation system, also developed by Torvalds. Git has a very tiny footprint and provides better feature support as compared to other software programs of the same category.
3 Notice how I used the term “remote repository” instead of a “central server.”
Note that there is no concept of a central project, but a well-known remote repository is used to keep the track of the “master” state of the repository. Several well-known projects use Git version control deployed either on-premises or using one of the hosted code storage facilities offered by third-party vendors.
The Git protocol is used by GitHub and GitLab (it’s a part of their name and the service that they provide) to manage project resources, track changes, and version the state of the project.
A few features in Git include:
• Branches
• Hooks
• Staging areas
• Workflows
Some of these features (like workflows) are supported in other
version control systems too. These features make it easier for the software engineering teams to manage the lifecycle of a project. Branches, for example, can support feature addition and feature try-outs. You can create a new branch, add the code that must be tested, and run a DevOps pipeline on it. A branch is an abstraction layer that can be used to create two copies of your code. Similarly, you can create hooks that process the incoming commits, and also manage the workflows for your contributions.