As computers become more powerful and the web becomes increasingly ingrained into our daily lives, the role of the web developer becomes more and more complex. A wide variety of tools exist to help programmers do their jobs more effectively, the Version Control System (VCS) arguably being the most important.
A VCS manages and tracks changes to documents, files and other collections of information. Popular Version Control Systems for developers include SVN, Mercurial and the immensely popular Git. These tools help us prevent issues we will certainly all come across at some point in our web development careers.
I’ve Made A Change I Didn’t Mean To Make…
Whether it’s a change to a single file or countless changes to your code base, we’ve all been there; the realization that you have just altered or deleted something you shouldn’t have. As the name suggests, the core concept of a Version Control System is the creation of versions of your code over time. Implicit in this functionality is the ability to revert to an old version of your code and undo changes that have been made.
I’ve Made Some Changes, But I Don’t Remember What They Were…
When working in a large file or a large code base, it is easy to get lost in your own work. With your code being managed by a Version Control System, you can easily see the changes you have made since the last time you have committed your code (“committing” your code is when you save the changes to code you have been working on). When using Git, the git diff command can be run in your project, to show the files that have been added, altered or deleted or it can be run on different versions of a particular file to see the differences. This feature is so useful that plugins have been created to integrate this behavior directly into most code editors.
My Computer Crashed And Now I Don’t Have Access To My Code…
Most VCS can run on a server, so your changes can be tracked and backed up remotely. This is very useful as it creates a copy of your work that does not depend on which computer you use. It only takes a few easy terminal commands: You can git remote add a server to which you can backup and git push your code to it. In the event of a computer crash, you can simply git fetch your codebase from that server and get to work.
We Can’t All Work On The Same File, Can We?
When you are working with other developers, collaborating on tasks can be difficult. If multiple developers work on the same file at the same time, it becomes very easy to accidentally overwrite someone else’s changes. Shouting “I’m working on xyz right now!” to your fellow coder is not the best way to work. Instead you can set up a remote Version Control System, where developers can git fetch a copy of the code onto their machine and work independently from other developers. Once everyone is done with their work, it is easy to merge all the different versions into a common file that incorporates everyone’s modifications. Sore throats at the end of a long day are now a thing of the past.
I’m Not Sure What I Accomplished Today…
Version Control Systems allow you to have a good overview of what you’ve accomplished for a given period of time. If you are committing your code regularly (ie, saving changes to your code), every time you fix a bug for example, you can easily see a log of all your commits (a commit is a marker that contains all of the changes that you’ve made) and have a nice list of all the tasks you have completed. This history also allows you to track down changes to specific lines of code, so you can source why a change was made, or how a bug first appeared.
Developers have also created tools that extend Git’s functionality to allow for time tracking as well as version management. This displays the amount of time between commits, creating a realistic view of how long it took you to solve an issue. This can be particularly useful when you are freelancing and you have to create invoices for your clients, or calculate how long it will take you to finish a project.
I Want To Try Something, But I’m Scared I’ll Break Something Else…
Version Control Systems allow for more advanced workflows which make working on a large codebase easier. A powerful concept known as “branching” is widely used in the software development industry. Branching is a great way to isolate changes to your code and allows for easy reversing of problematic code.
So, what is branching? Like the name suggests, branching allows you to create a “master branch” (in grey below), which usually coincides with the code that is in production. Different versions of the code, named branches (in yellow below), shoot off this master branch for every change in functionality you want to implement.
This concept is incredibly powerful as it allows you to experiment with your code, without changing the “master branch”. The master branch continues to evolve independently of whichever branch you are working on. When you are done with your changes, you can merge your branch back into the “master branch”, which will apply both the changes in your branch and the changes that have occurred on the “master branch” in the meantime.
Branches are usually created for any change in functionality, for example the creation of a new feature or fixing a bug. The isolation of changes that branches provide allows you to experiment with your code without the fear of breaking things in your live code, because, should things not work out, you can simply erase the branch and nothing in the “master branch” will have been affected by it.
Whether you are working on a complex code base or simple scripts, it’s always a good idea to invest some time in learning how to use a Version Control System. Version Control Systems are incredibly powerful tools that can help you get things done more effectively, make it easy to reverse what you’ve done, aid experimentation and back up your work - altogether making your life as a web developer significantly easier.
What You Should Do Now
- If you’d like a step-by-step intro to find out if web dev is right for you - sign up here for our free 7-day web dev short course.
- If you are interested in becoming a Web Developer check out our web development course (you'll learn the essential skills employers need).
- If you’d like to speak to an expert Career Advisor for free about how you can really get a new job in tech - connect with us here.
If you enjoyed this article then so will your friends, why not share it...