Version Control Systems Tutorial 101 using Git and SourceTree
In this post, we're taking a look at the importance of a good version control system, and why Git continues to sit at the forefront of the industry when it comes to distributed version control systems.
It is important that your development teams use Git and version control from an early stage in your project. This will ensure that the project is built on a solid base and that a standard is maintained. A good version control system will enable you to collaborate and scale in a managed way, as altering your development workflow can have an impact on your entire business.
Take a look at the following example, and you’ll see what we mean.
Version control systems overview
Imagine that following an initial consultation, a developer starts writing an application for your company calledsourcetree_tester. They begin writing code to a file. After several revisions, the developer decides it’s time to back up this file. The filesourcetree_testerwill be backed up to a file calledsourcetree_tester_backup.
A few days later, the developer wants to make a more recent backup, so they createsourcetree_tester_backup1.1. After a few months of revisions the developer’s desktop looks like this:
It means that if at any time the developer decides they have gone down a bad route, they can just open up a recent backup and start again from there.
It works, so what’s the problem?
A very basic version control system or VCS, such as the one just described, can be good for a small project, but what if instead of a file we have a project made up of multiple files? In this case, every backup now takes space and time to create. The version control system ends up looking like this:
The developer could get around this by backing up the directories — which will be time and space consuming — or alternatively, by only backing up the files that have changes, but this would quickly get confusing and is likely to lead to expensive errors and downtime.
Collaboration causes confusion
Say a second developer now joins the team. Both developers now need to collaborate on writing the application. The code is packaged up and sent off to make changes.
The second developer makes changes and sends the code back inside the new-code folder, as shown above, along with a text file listing changes made.
The team now has three main sourcetree_projects and an exponential number of backups and revisions. To make things more complicated, both developers have been making changes at the same time. These will now need to be manually merged without causing any bugs or breaking the code.
The situation quickly escalates with additional developers, revisions and time. This inevitably leads to bugs, errors, poor practice and stress, which then leads to loss of time and resources.
A good version control system (VCS)
Based on the case study above we can see some of the attributes of a good version control system:
- Acts as a backup of project files
- Contains all the versions of a project from conception to deployment
- Shows all the changes made (revision history)
- Allows multiple developers to work on the code at the same time with the ability to merge changes
- Prevents repetition and errors by automating the version control system
Using Git as your version control
Git does not stand for anything, it’s just the name that the inventor Linus Torvalds gave to the system.
Git is an example of a Distributed Version Control System (DVCS). Centralized systems have a single location where code is pushed and pulled to. Distributed systems mean every developer’s working copy of the code is also a repository that can contain the full history of all changes.
There was an epic battle, similar to AC/DC (Edison vs Tesla) between distributed and central version control systems a few years ago. The outcome was that DVCS such as Git rose to completely dominate version control
In addition to being distributed, Git has been designed with performance, security and flexibility in mind. Git is the best choice for version control today. While there are many version control systems (VCS) available, Git is generally considered the de facto standard.
Resources for getting started with Git
Git can be difficult to learn, but you shouldn’t let that intimidate you. Fortunately there are lots good resources, as well as third party software tools and services that are already integrated with Git.
Now you know what DVCS means, why not try out the DVCS desktop client Sourcetree to help you get started? Sourcetree is a free Git client from Atlassian for Windows and Mac. It simplifies how you interact with your Git repositories, so you can visualize and manage your repositories through a simple Git GUI and focus on coding.
Check out the links below to learn more about Git.