The basics of version control using GIT Part 1

What is version control?

Any developer that has worked on more than a handful of projects will be able explain why version control is so important in todays development environment, and while version control is not technically needed for some projects, it is an essential tool in any modern developers arsenal.

Version control allows you to take snapshots of your source code (known as commits) at predefined points, these points are usually set by the developer and are commonly selected when a determined milestone has been reached, one example of this would be to commit source code changes after completing the development of a requested feature that has been defined in a web development specification.

Why use version control?

Version control has many advantages, the first being that as a developer you have access to a repository of information which includes every edit of every file that has been committed to the repository, this is especially useful if the developer needs to “roll-back” a file to an older version.

Collaboration is also another huge benefit, without a version control system in place developers generally have two options :-

1) Work from the same central server remotely.
2) Work locally using WAMP / MAMP or local apache install.

There are quite a few potential problems with working in either of these environments, the first is that if everyone works from a central server remotely then there is a high risk that two or more developers will end up working on the same file which will eventually lead to data-loss when they start overwriting each others changes. The second issue is that if all developers work locally, there is no system in place to merge all the file changes they have made individually, this could be done manually, but this would be extremely time consuming and prone to many errors.

The bottom line is that version control systems allow multiple developers to collaborate, and keep track of every stage and every milestone of a project, if multiple developers are working at separate points in the same file then GIT is generally smart enough to “merge” these changes together, if in some cases two developers are working in the same codebase and in the exact same section of code, then a version control system will show the developer the differences in that file in a graphical or text based manner and present them with options to correct it (much quicker than doing this by hand).

With more advanced features like branching and tagging the developer is able to keep track of every nuance of a project.

GIT is distributed version control

There have been many version control systems in the past, but arguably the two most common in recent years are Subversion (SVN) and GIT.

Subversion works in a very similar way to GIT but is primarily based around a central repository that the developer must be able to connect to before making any commits or receiving any updates, GIT however is a distributed system, which means that each developer has a local GIT repository stored on their local machine which they can commit to and update from, and because this is on the local machine the developer would not need to be connected to any central repository.

Once the developer is ready to share his recent source code commits with other developers then a “push” would be made from the local repository to any other repository. This means that while a central repository would still be an advantage it isn’t necessary for the developer to be able to connect to it before any changes can be staged and committed.

Another advantage of distributed version control is that every developers local copy is identical to everyone else’s including any central repository that may be in place, this means that if a central repository server fails, then this can be restored from any other of the local repositories that other developers may be holding.

In the next part of this post we will look installing GIT and managing your code using it.

This entry was posted in Development. Bookmark the permalink.

Comments are closed.