What is Version Control System and Why do we need it ?
Today I will explain about Version Control System.
What kind of questions comes in your mind for Version Control System???
I guess those would be like what is Version control system and why do we need any version control system for our software development.
I will give an example before going to give accurate definition for version control. Like when we were in college we prepare our notes. We complete our notes first time and give it a name as Version1 and after some time we came to know that we need to update notes (we can add some diagram) or from anyone we got some more valuable points and we update our initial documents and we will give it a name as Version2. In this case we did our changes in Version1 file only and we don’t have backup file for Version1, now let’s guess we make more and more changes like this and we are at stage Version5. But now we realized that the material we have added at Version4 stage is not correct and we don’t want that in our file……. Now we don’t have separate copy for any update. So we are already messed up right… …as we don’t have backup copy ……..If in this case if we would have used Version control then we can easily get our Version4 file and all details what we update till now and who has made these changes. The system that maintains our versions is Version control system.
So maintaining our changed file/documents/product/application/ is done by version control system.
In our software industry our application /product are so big includes a large number of files, So it is must that we should have some system that can maintain files /products with all changes called versions and we can use different versions whenever required. Without using any Version Control System it becomes very difficult job to maintain any software product.
Problem we faced without Version Control System (VCS):
- If one user is working for file1, at that same time nobody can work on that file otherwise their changes may be lost.
- It is very lengthy and time wasting to maintain changed file or changed product.
- Giving proper naming for different version is difficult.
- It is very difficult to know what is the exactly difference between different version.
- Backup for product/application is very tough work.
- It is very difficult to know that who made changes and why in any particular file.
In VCS we can pack all different versions and can work on latest version. We can restore previous versions when required.
Whenever we saves any new version we will provide it’s detailed e.g. what changes we made and why so that it make user clear to know about different versions.
Let me define Version control: “Version control is a system that records changes made in any file/set of file over the time. Version Control System keeps track of every modification to the code with detailed reason and time stamp. Version control system (VCS) is also known as Source code management (SCM) tools or Revision control system (RCS).
Basics of Version Control:
- Version Control are the software that manage changes to files, e.g documents, images, code etc.
- Keeps a history of working versions of projects
- Know who made changes as well as when and why
- Rollback entire project back to a previous state
- Compare changes over the time
- Merge conflicting changes
Benefits of using a version control system are:
- Saves us from creating multiple backups of your files
- Allows multiple people to work on same file
- Tracks changes and also who have made those changes
- Easy to switch back to older versions as and when required
- Protect our source code from any human error or any unintended results
- It makes development faster and preserve efficiency
- Makes you more productive
There are three types of Version Control:
- Local Version Control
- Centralized Version Control
- Distributed Version control
- Local Version Control:
In this approach all developer shares same file system. And in this approach developers ideally maintain a file in his local computer and when he work on those files and made some changes he save his work with version number (Version1) on his local system only and again when he made some change he will give this different version number(version2).
Disadvantage of this version system:
- If developer give wrong version number or if he forget what was the latest version in that case it will create a problem and he can lose some data
- one more disadvantage is that all files are on his local computer so it is not so secure and if something happens to his system then he will lost all his data.
- In large team very difficult to collaborate with different team members.
e.g. Revision control system (RCS)
2. Centralized version control:
It is a client server model, the whole code will be in center repository server, In this approach developers use a shared single repository. A centralized version control system provides a server software component which stores and manages the different versions of the files. The developers, who are working on this project, need to connect with server and can copy (checkout) a certain version from the central sever onto their local computer and they can work on that. Developer can retrieve just files he need to work
Advantage of this Version control system:
- All files are on central server and it is secure and other developers also know what developer is working on what file and they can be in touch with everyone’s changes.
- This version control is maintained by admin, all permissions are controlled by center admin administrator and they can give read/ write permission to dev.
Disadvantage of Centralized version control systeIf Central server goes down, then other developer can’t perform most of the operations.
- Developer need to be connected with internet to work with central server so limited capability for offline work
- Version control is not available on local system
- If central server gets corrupted, it will be very difficult to recover all code, and all history will be lost
e.g. Subversion (SVN)
3. Distributed version control system:
In this approach the main server (central repository) have all version of files and the developers who want to work on this server they need to copy whole code from the server to their local machine and afterward they can work independently on their local systems. This copying process is called cloning and the resulting repository can be referred to as a clone. Developer can retrieve an entire repository
Advantage of Distributed version control system:
- If developer wants to do any operation he doesn’t to need connect with internet. When he finishes his development and testing, he can push back his changes to the main repository.
- If master server goes crashed, all computers have copy of main code.
- He will allow to work multiple developer at same time
- Every clone contains the full history of the collection of files and a cloned repository has the same functionality as the original repository.
- By using DVCS version control is also available on the local system e.g. GIT