Suppose you are working on any project with the team of 100 software developers and suddenly one day your pc stop working and all your data get deleted by mistake and all the data of the project was in your pc. Then?? What will you do?? Isn't it a big problem?
And also it will be very difficult for everyone to contribute to the project remotely if the data of the project will be divided! So VCS and Github are there to solve our these problems! we have our saviour with us Git & Github!
What is Git?
Git is a version control system! Now let's understand version control system and it's type in detail first.
Version control systems are used in managing and in keeping track of the changes done to the source code over time. As you know in making of the software collaboration of more than one developer is there, so it is important to track the changes done to the source code.
Using a version control system if a mistake is made by anyone in the source code you can return to the previous version easily. You can take the example of Open-Source Projects where more than one developers from different parts of the world contribute to a single project, and each one of them contributes to the project in some specific kind either by finding a bug in the code or by adding some new feature or by updating the README section.
The version control system assigns a unique hash code for every modification done to the source code. It is useful in reverting to the previous version of the code.
If you do not use any kind of version control system you will run into problems like not knowing what changes you have done to code and when you have done it. If you have done any mistake in the code, the code will not work properly and you will not be able to revert to the previous version which was working as you were not tracking it. Using the version control system you can also check which lines of code are added and which are deleted. This can help you identify the problem in the code more easily.
The version control system mentions the date and time also, on which the modification was done. It also mentions the name and email id of the contributor contributing to the project.
Suppose you are working with a team of other five developers on the same project and you want to add some new feature to it but you are not confident that it will work properly or not, you are afraid that if it doesn’t work properly then the development process will stop. Here the version control system helps , Version control system gives us the comfort to create a separate branch for every contributor who wants to add something new or wants to make changes in the code and when they work properly, they are merged in the main code.
What are the different types of VCS?
There are three types of the Version control system:
Local Version Control System
Centralized Version Control System
Distributed Version Control System
- Local Version Control System:
In simple language, the Local Version Control System is the system in which you track all the files and store them on your computer.
You are feeling bored! Right? I can understand!!
Let’s take an example to understand in a better way:-
Let’s suppose you have written 100 lines of code and you saved it with the name “Folder 1” and then after someday you thought of adding or changing something in it but you don’t want to disturb the version 1 directory so you created a new directory “Folder 2” and copied all the code of version 1 in it and started working on it, but after the modification, you saw that the code is not working properly, so you revert to version 1 directory. This is how you can keep track of the files using the Local Version Control System.
This approach is very common and simple but it is also incredibly error-prone. It is easy to forget which directory are you in and in which directory you have to make the change so there is a high chance of error.
- Centralized Version Control System-
As you know that to make a software, collaboration is very much necessary and for collaboration there should be a communication between the contributors contributing to the project. Using the centralized version control system everyone contributing to the project knows to some extent what changes others have done.
In the Centralized Version Control System, there is only one repository on the server containing all the versions of the code. Everyone who wants to make any change in the main code on the server, they have to commit the changes they want to reflect in the central repository. To view the changes done to the repository, other users have to update it from the server.
Suppose four developers are working together on the same project. Developer “A ” wants to make changes in the project, so first, he made those changes in his working copy on his local system, and after he is confident about the working, he has to commit those changes to reflect them in the central repository. Now to see those changes in their working copy other contributors contributing to the project have to update it from the central server.
So what is the problem in using CVCS for version control? Do you Know?
No? Okay! No problem, we will learn together :)
The major drawback of this type of version control system is that all the versions of the code are on the server so if it goes down during the period of development, collaboration will stop.
If the hard disk of the central database becomes corrupted and you have not kept any backup of the code files anywhere, You lose everything and you will have to start from the beginning.
This does not seem to be a very big problem to you. Right?
But when you’ll work in some big tech giants where code is in millions of lines.
Yes!!! You’re Right!! Then It will be a big problem!!
- Distributed Version Control System:
Distributed version control systems contain multiple repositories. Each user has their working copy where they can make the changes without disturbing the main code. Every clone has a full backup of data. Using Distributed Version Control you can work jointly on the same project with the different group of people. When you will commit, it will reflect those changes in your local repository and you have to push the changes to make them visible in the central repository, and to see other’s changes you have to pull it from the central repository.
Git is a type of Distributed Version Control System which is mostly used nowadays. Git is widely used in the open-source sector. Using Git, it becomes easy for anyone from anywhere to contribute and it becomes easy to manage the code.
So, let’s summarize what we have learnt till now:
Using a version control system it becomes easy for anyone from anywhere to contribute to the project.
Using a version control system one can make changes in the same repository at the same time without affecting the development process.
Using a version control system it becomes easy to revert to the previous version if you have made a mistake.
Using a version control system it becomes easy to identify the mistake in the code.
Using a version control system you can know what changes have been made to the code, who have made them and when it was made.
So, we have completed the basics of version control systems in this blog.
In my next blog post we will learn about Git in detail!
Excited! Right? I’m also excited…
So, for now I’m ending this blog post.
If you want to connect with me follow me , we will meet again in my next blog post :)