Okay, maybe it’s not that dramatic, but having a version control system can save your project – if you use it properly. In this article, we’ll look at what version control is and why it matters. This article will serve as the introduction to a series on version control and GIT.
What is Version Control?
At its most simple, a version control system, or VCS, looks at a file (or, more commonly, a group of files) and tracks changes over time. Each “snapshot” is stored as a version, and anyone involved in the project can make a new version. The VCS allows you to look up and interact with specific versions, which means a team working on a project can create multiple versions simultaneously to see which is a better option. Different versions can even be combined! This allows teams to split responsibilities, work on various project tasks, and blend their results together.
Think that sounds interesting, but not sure how it works? Let’s look at some examples.
Example 1: Business Contracts
Contracts are an unavoidable part of doing business, and edits are an inevitable part of working with contracts. Keeping track of all the different versions of the same contract for various clients and engagements, especially when multiple employees or computers are involved, can get complicated, but it doesn’t have to be. With a VCS, each version of a contract can be saved as a snapshot to be referenced later. Along with the contract itself, the VCS allows you to see who made changes, the specific parts changed, and any comments about the change by the individual who made them. This can be very helpful when you want to know why a particular clause was redlined from a contract written three years ago, or if you have a particular language you use when working with some clients but not others.
Example 2: Marketing Plan
Anyone who has worked on a creative endeavor can tell you – for every design selected, there were a number of drafts and alternate options explored. Version control is great for experimenting with different layouts, colour schemes, and other visual elements. An additional benefit of version control is that users can pull in parts from different versions and combine them. For example, suppose a decision-maker liked most of one design option but preferred a specific component from an alternative or previous rendition. In that case, you could simply go to the “snapshot” with the desired component, grab it, and copy it into the current design.
Furthermore, version control is great for collaboration. Because multiple versions can be developed concurrently, team members can pull from the same starting components and work on various pieces or design options. This allows everyone to make changes without interfering with each other’s work. When a piece is approved, it can be merged into the master version.
Example 3: Development Project
The most common use of version control is for development projects. Developers can work on the source code for a project simultaneously. They can maintain a stable, production version of a project while also creating different versions behind the scenes to add new features, address bugs, or experiment with design reworks. Version control is a critical component of software development workflows. Not only does it help enable development, but it also provides an added degree of security. With version control, anyone who has access to the project can access the various versions and its history. This means if something happens and a server goes down, you can get back up to speed quickly. All you need to do is grab your source code from your version control system and re-deploy it to a new server. You don’t have to worry about re-creating the entire project from scratch.
For the remainder of this article, we will focus on version control in the context of software development. Still, a lot of the principles discussed apply to other applications as well.
Why Is Version Control Important?
Okay, so now that we have a basic understanding of what version control is, let’s talk about why it matters. GEO Jobe’s Dylan Drake puts it nicely:
The amount of headaches that a mature VCS reduces is invaluable. A good VCS is essential for multiple devs to collaborate and develop in parallel on a code base. It allows for easy feature development while maintaining a stable master build, a historical record of all changes, who made them, and when, with the ability to revert back to a previous state. To me, there is no DevOps without version control. So many processes are streamlined by just a few GIT commands.
– Dylan Drake, Software Engineer / DevOps
Let’s look at how version control impacts each of those areas.
Concurrent Development
When you have a software product, whether it is for internal use or something you sell, you will have multiple versions. At the most basic, you will have a stable production version and a development version (though many projects have more than this). A VCS makes tracking those versions much simpler. Each version can have a named “branch” in the central database, called a repository. If different teams are working on various versions of the application – for example, updating an application to use language, themes, and branding appropriate for localization in a particular subset of countries – they can create more versions. The VCS will keep track of every version and its changes while making it simple to keep things separated.
Another perk of working with version control is that multiple developers are able to work on the same project, even the same file, simultaneously without interfering with each other. They can each do the work they need to, then merge their results when they are finished. When developers can work together, they can compliment each others’ skills and get work done more quickly.
For example, just this week, one of my teammates and I were working on a widget together. At one point, my teammate was working on a section of code that checked a configuration file to get the list of layers and display that list to the user to select layer(s) to search. At the same time, I was working in the same file on code for taking an input geometry input and checking for intersecting features (using a single test layer). When we were both finished, we were able to merge our changes and have a widget that searches for features within a given geometry on a user-selected set of layers. Without a VCS, we wouldn’t have been able to work on this file together.
Stability (and Security!)
As mentioned above, software products often have multiple versions at the same time. Being able to track those versions and their changes is vital to the longevity of your product. As the product grows and changes over time, you will release updates. Sometimes, something can get missed in testing and pushed to a live version. A VCS allows you to quickly grab the previous, stable build and re-deploy it when that happens.
Version control can impact stability in terms of working with multiple developers as well. For example, suppose two different developers or teams are working on different components that interact with each other. In that case, it is not uncommon for some part of the application to break during development (which is why your development and production environments should always be separate). If the files for the project were in one place without version control, and each team overwrote their respective parts, there wouldn’t be a way to get the stable build back. With version control, you can maintain one core build, then merge in changes one at a time. If there is a conflict, you can look at the different versions to see exactly which parts in which files have changed (sometimes it is as simple as a variable name being updated). Using a version control in this way avoids the stress of something breaking and not being able to fix it, while also making updating the two new components to be able to communicate with each other much simpler. It’s a win-win!
A final way version control aids in security and stability has to do with the physical machines involved. Sometimes, unfortunate events happen. A computer may get damaged, the software may fail, or an employee may unexpectedly leave the company and their machine is wiped without a backup*. In any of these situations, if there is no version control, any of the code on the computer could be lost. If only one developer was working on a project, you could lose years of work as a result. With version control, however, there is no longer a “single point of failure”. As long as you have access to the version control system, you can copy the project to a new machine and continue where things left off.
*Note: There are exceptions to this particular scenario. We will get into the different types of version control systems in a future article.
The Importance of Tracking Changes
With multiple people working together on a project, it is crucial to track changes between different versions. If you’re just working with a handful of files, this might not be too difficult to keep track of manually. Still, if you look at something as robust as Clean My Org, which has hundreds of files, it is nearly impossible to keep track of what changes occurred where, when, and why on your own. This is one of my favorite parts about using a VCS. With a version control system, you can see which files (and even which lines in a file!) change between different versions. This makes it much easier to track changes. Even this article was written using a very simple VCS!
Sometimes, especially with projects that are multiple years old, it can be difficult to remember why specific changes occurred. One of the nice things about working with a VCS is that they often allow you to include comments when recording changes. This is extremely helpful when looking back at old work and trying to figure out why something was done a particular way. Sometimes it is due to a project restraint, limits in available supporting technology, or the requirements of working with a particular API. Tying messages in with changes offers the additional benefit of providing explanations even when the developer who initially implemented the update is no longer available to explain their reasoning.
The final reason to track changes is that it allows you to undo them. While you may hope to never find yourself in a situation where you have to undo a change, it is always better to be prepared. With a single file, that is as simple as a Ctrl or ⌘+z. With changes between versions in a software product, it is a bit more complicated. Even if you knew every change performed across all the files in a project, it would still be very time-consuming to undo all of those edits manually. By using version control, this is much simpler. Since a VCS tracks all the changes in the different versions, undoing a change, or even several, is often as simple as reverting to a previous version. In most VCSs, this can be done with one command.
Until Next Time…
If you’ve never heard of version control before, hopefully, you now know what it is and why it’s essential. If not, reach out to us on Twitter or via e-mail, and we’ll be happy to keep the conversation going. Want to learn more? You’re in luck! This article is the start of a series, so check in next time, where we’ll talk about the different types of version control systems and how to get started.