Skip to content

What is Version Control?

Abinav Seelan edited this page Aug 30, 2016 · 4 revisions

Writing code is a messy affair. There's a lot of trial-and-error. Sometimes introducing a new line of code can completely break your application!

Though the traditional ctrl+z-ing is still a thing...you really can't do it if you have multiple files and/or don't know how much to remove to bring your code back to it's last working state.

This is were a Version Control System (VCS) comes into play. A VCS manages versions of your code so that you can go back and forth between these versions and if a version of your code is wrong and breaks your application, you can just go back to a previous version of the application to bring it back to a working state.

Wait....what? Can you elaborate?

Ok. So imagine you've written some code. Let's name the current state of your code version 1. Now you go ahead and add some more lines of code to this version. Let's call this state version 2. You run your code and your code runs flawlessly. Happy days!

But now you want to add some more code to add some new functionality to your code. This brings your code to a new state. Let's call this version 3. You run the code and...it doesn't run. It breaks. You sad. =(

Now, to fix this, you'd have to go into all the files and see what needs to be undone to bring your code from state version 3 to the perfectly working state version 2. Such hassle!

Now with a Version Control System, things are a little bit easier. A VCS keeps track of these version changes in the form of snapshots of your code. In the above example, when we know that Version 3 of the code isn't working, we can just immediately jump back to the previous version!

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.

Types of VCS

Version Control Systems come in two forms

  • Centralized VCS
  • Distributed VCS

Centralized VCS

Centralized version control systems are based on the idea that there is a single “central” copy of your project somewhere (probably on a server), and programmers will add their changes to this central copy.

Adding (also known as committing) a change simply means recording the change in the central system. Other programmers can then see this change. They can also pull down(download) the change, and the version control tool will automatically update the contents of any files that were changed.

Distributed VCS

Distributed VCS systems do not necessarily rely on a central server to store all the versions of a project’s files. Instead, every developer downloads (also known as clones) a copy of a repository and has the full history of the project on their own hard drive. This copy (or “clone”) has all of the metadata of the original.

The developer can then proceed to modify the files on his/her own system, and when the time comes to share this code, it can committed back into the central server.

Distributed VCS has caught traction over the last decade as it allows developers to

  • work on things locally
  • not rely on internet to connect to a central server

Clone this wiki locally