What’s Version Control in Web Development and Why Do I Need It?

Alexandre Ouellette, contributor to the CareerFoundry blog

As computers become more powerful and the internet becomes increasingly ingrained into our daily lives, the role of the web developer becomes more and more complex.

Just like there are a whole lot of tips out there for those learning, so too a wide variety of coding tools exist to help programmers do their jobs more effectively, the Version Control System (VCS) arguably being the most important.

  1. What is Version Control?
  2. Why Version Control Systems are useful
  3. Final thoughts

1. What is Version Control?

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 (not to be confused with GitHub). These tools help us prevent issues we will certainly all come across at some point in our web development careers.

2. Why Version Control systems are useful

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 (especially if you’re working as a remote web developer).

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 time-tracking tools that extend Git’s functionality to allow for time measurement 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.

Final thoughts

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.

If you’d like to read more about the world of coding, check out these articles:

What is CareerFoundry?

CareerFoundry is an online school for people looking to switch to a rewarding career in tech. Select a program, get paired with an expert mentor and tutor, and become a job-ready designer, developer, or analyst from scratch, or your money back.

Learn more about our programs