Why use git?

The git is a Version Control System, in short, it is known as VCS that is a part of the software industry in day to day life. The git makes life easier by automating hard work that we need to do it by our self manually.

If we didn't have git then we need to copy the file, again and again, modify the code and rename the file. Like as shown below.

hashnode-git-blog.jpg

Cons without VCS :

  • The problem with copying the file, again and again, is that we need to make a copy of the file whenever we are modifying the code. and after modifying we need to rename the file.

  • Generally in Software we work in a team after modification we need to mail the code file to our team whatever changes we made and they will also do the same.

  • In previous steps we created multiple copies of the file. It is very hard to tell which is the latest copy and which file was created before which one.

  • When we mail the files to other teammates it is very hard to compare the files for changes they have made. This will may lead to the bugs.

  • Also, If teammates are sharing their piece of code it is very hard to keep track of who, when, and why the changes were made in the code.

Note: Before git and VCS there were some tools like 'diff' and wdiff using which we can just compare the files. And there are some graphical tools like meld, KDiff3, and vimdiff which are more advanced than diff etc.

Centralized version control :

This is another VCS in this one the code is stored in the central server you need to be connected to the server to access the code and its modification and updates.

Disadvantages of centralized VC :

  • In this we need to be always connected to the Server. We cant access the code from anywhere.

  • If the server was down or got crashed then the team cant work on the project.

Git :

Let's understand how git can help us with a story Imagine we are cooking some dish with the help of a recipe book. we need to follow step by step procedure to cook a particular recipe. and while cooking you are also watching television. In the beginning, everything was going fine. While watching television you have messed up some of the steps. The dish was ruined because you didn't follow the guide properly.

In the real-life, we can't reverse anything but by using tools likegit while writing code if we have made some mistake we can always rollback from problematic changes to the stable version of the code.

We can use the git as a time machine to move forward or backward.

Git is useful to know the history of modification in a much-simplified way in an editor. We can also write commit messages before to tell why the change was made.

Advantages of git :

  • The code was stored locally on every machine of the team that is every team member had a copy of their own code because of this no connection of server or internet was required to work on a project.

  • The work will not stop because of some internet or server problems.

  • Git we don't need to make a copy of the file, again and again, to make changes to the file. Because the git will take care of the changes made by who, when, and why.

  • Using gitwe can collaborate with other developers like on open source software.