Tuesday, 9 July 2019

Introduction to Git

Necessity is the mother of invention.
The need for "Distributed Version Control System" for the development of the Linux Kernel made Linus Torvalds to develop Git.

What is Git :
        In a single line, we can define Git as a "Distributed Version Control System".
        A version control system is a tool that tracks changes made in the files over a period of time.
        Git helps us to track changes made in files. when we add a file or modify an existing file ( to a directory which is being tracked by Git ), Git helps us to determine - part of a file changed, a person who changed it, and with commit message why it was changed.

Version control systems used earlier :

        I remember when I was in my bachelor Degree (BCS), I used to create "folders" for maintaining all the important source code files of the project. I used to give names to the folders like - "Web Project",  "Web Project New",  "Web Project New 1",  "Web Project New 2" and so on.
        Mine method for version control is very common. For every new version, I used to copy the whole folder and makes changes in the newly created folder.  But this method was not so good, because as project size increases its hard to manage the project and also my friends cannot contribute to my project. this method of copying files into another directory (folder) can be termed as "Local Version Control System".
        When a project is large & requires more than one developer to work on a project; then the project needs to be stored centrally. when a project is on a centralized server then all development team can work (collaborate) on a project. Also, a centralized server contains all versioned files, so any developer can check out files from here. this method of having a "centralized server" for working together on a project can be termed as "Centralized Version Control System".
    But a Centralized Version Control System also has the following serious downsides :
    - If the centralized server goes down for a certain period of time then during that time nobody can work on a project.
    - If the hard disk of the central database is corrupted & proper backups haven't been kept then you will lose the whole project.
    Disadvantages of "Centralized Version Control System" is overcome by "Distributed Version Control System".
        In "Distributed Version Control System" all the data (files) is kept on each collaborators machine. so even if the central server gets corrupted then all the data can be retrieved from another machine (from the machine who is collaborating on the same project).

Advantages of Git :
    Speed: Most of the Git operations are performed locally on the computer without the need of internet. Internet is only needed when we want to collaborate with team & for storing versions in a centralized server.
    Free and Open Source: Git is free to use for managing your project without paying a single rupee. Git is "Open Source" means you can modify Git source code according to your requirements.
    Security: Git guarantees that it's impossible to change its content of any file or directory without Git knowing about it. The mechanism that Git uses to provide such integrity is "SHA-1 Hash".
    Backup: Files of a project on every collaborator's machine, hence it can be used for recovery of data. The chances of losing data are very rare.

4 comments: