September
2013
25

Use Version Control for software development

Git version control

Allow me to explain shortly version control first.

 

Version control or revision control consists in the management of changes of a software project. Every change made to the code and uploaded to the version control system is tracked along with who made the change and comments explaining why they made the change.

 

There usually is a central repository where the code is stored along with all the history of those files. People connect to that repository, get the files, work on their own programming environment and then submit the changes back to the central repository. That way people always know which is the most “up to date” version, instead of having to ask everybody.

 

The “standard” way of working with a version control system is:

  1. Check out the project from the central repository
  2. Make Modifications to your code
  3. Submit the changes back to the central repository

 

You also have “branches“, which are a copy of the repository¬† in order that you can have modifications that can happen in parallel along both branches. They are very useful for new features, testing or fixes. After you verify that the branch is working correctly than you can merge the changes to the main

 

version control branches
version control branches

 

For instance, imagine you have an Instagram like website and you would like to add a new feature consisting in new types of images where the user uploads a picture and a message and it appears written over the image. You could create a branch copy of the “main” and call it “images with text”, develop the feature on that branch and then when you know it works, merge the changes with the main branch again. By acting this way, you can have different teams developing different features without bothering each other.

 

Among all version control systems, I prefer Git. It allows you to have a central repository in Github or Bitbucket (in my case, I use Bitbucket) and work with a local repository on your computer. It modifies a little the workflow but it is way better to be able to work offline. With Git the workflow is something more like:

 

  1. Check out the project from the central repository
  2. Make Modifications to your code
  3. Submit the changes to the local repository
  4. Submit the changes back to the central repository

 

That way, for my personal projects, I can work on my computer and when I’m done working I just upload the changes from my local repository to my central repository, instead of doing lots of uploads. I also use Git for WordPress development and for this site development; it allows me for example to update WordPress and plugins on my test computer, see if it works and then automatically upload the changes to my wordpress server. That way I get an almost zero risk update (0% risk free is in my opinion impossible).

 

Of course there are loads of other reasons to use Git but I think I will leave that for another post. If you do not know Git or don’t like it (congratulations, you are one of the few people who don’t) you have alternatives like subversion or mercurial, which work really well also.

 

I don’t say that everybody who codes should use Git (but please, feel free to use it and try it), but I DO say that everyone who codes MUST use version control. Not using version control is one of the biggest and greatest mistakes when developing software, even if it is for a small project.

Share your thoughts!