version-control-systemAs the web becomes increasingly more tangled up in our daily lives, the role of the web developer becomes increasingly complex. Mobile compatibility, security and on-site optimisation are all key areas for developers to focus on, but with complex coding tasks comes great responsibility: a minor mishap here or there and the entire functionality of a site can be compromised.

Thankfully, there are a plethora of tools out there to help web developers to do their job more effectively. Version control systems are one example of a powerful tool that should never, under any circumstances, be overlooked.

What is a version control system?

A version control system, or VCS for short, is a tool that tracks and manages changes to files, documents or other data. One of the most popular version control repositories is Github, a site which allows persons to collaborate on coding projects. It implements version control perfectly, and records changes to file-sets over time so that users can recall older versions at a later date (if they need to revert back to the original code after making an error, for example). In short, version control is essentially a slightly more complex, web-based embodiment of the “Save As” function on your word processor.

What happens if you make a coding mistake?

Whether it’s a change to a single line of code or a complete overhaul of your entire code base, most web developers have experienced the sense of dread when something has been altered or deleted when it shouldn’t have been. It’s not enjoyable, but it’s an everyday occurrence for coders, which is why the concept of a version control system is so important. Being able to revert to an older version of your code allows you to undo any accidental changes for the better. On a really bad day, it might just save your site (and potentially, your job).

Can I save time and implement code from previous projects?

DeployHQ is an interesting service which allows you to both automate and manage the deployment of all your web development projects from a single base. It allows you to connect your file repository and is compatible with self-hosted repositories or sites like GitHub and Bitbucket. Simply set up your servers, create your commands and deploy your code. If you’re still using FTP, you might want to have a quiet word with yourself.

What happens if you don’t remember the changes you made?

Again, most web developers will be familiar with how easy it is to get completely lost in your own code. When your code is being managed by a version control system, it’s easy to see the changes that have been made since you last “committed” or saved your code. Github, for example, allows for a ‘git diff’ command to be run in a project to highlight files that have been altered, added or deleted. It can be run on different versions to help you highlight the differences between them. It’s such a useful feature that most code editors now feature plugins that integrate this behaviour into the software.

What happens if my computer crashes and I don’t have access to my site?

Most version control systems can run on a server, allowing for any changes to be remotely tracked and backed up. The beauty of this is that your work is no longer dependent on the computer you use. With some simple terminal commands, you can tell your version control system which server you want to back up and push your code to.

What if I can’t remember what I’ve accomplished?

Version control systems are useful for keeping track of achievements and accomplishments. If, for example, a client or boss wanted an example of the work you’ve completed over a certain period, you can happily show them each of your “commits” (saved changes to code) in a neat list.

What if I want to try something new, but don’t want to risk ruining my site?

This is where branching comes in. The concept is popular across the web and software development industries. As the name suggests, branching allows you to have different offshoots (or ‘branches’, if you will) of code. This allows you to experiment with your code without ever going near the “master branch” – the live version of your site, in other words.

Whether you’re working on simple scripts or have gotten stuck into more complex code, it’s worthwhile understanding how to use version control to your advantage. A VCS will ultimately aid experimentation, make it simpler to reverse mistakes, help you to back your work up and make your life as a web developer much easier.