Hello Friends, In this article I will help you to understand git with simple explanation. No matter if you are new to programming or an experienced programmer, this article will help you to understand the basics of Git.
What is Version Control?
Before understanding Git, you should be aware about the version control and why do we use it.
Version control is used to have a storage of different versions of your file at a location. The location should be accessible for future use.
The version control system(VCS) can be used to compare two versions, revert to previous version, revert the file to a particular time stamp in past or make note of who did the changes etc.
The file can be a image file, document file or some code file. There can be many reasons to store the file at a central location. These include sharing with some one else, having a backup copy of the changes done at some particular time to name a few.
Types of Version Control:
There are three different type of version control that exist till day. I will discuss all the three one by one with brief history and examples.
First Generation:Local Version Control Systems
This is the initial generation of the version control. The version control was introduced in the time when programmers used to keep the changed files at different location maybe in a folder named by the time stamp or the change name.
RCS(Revision control System) evolved from the above method of storing files. This is the control system where we can maintain only the version of single file.
There is no networking involved in this system and it stores the revision in the tree structure on the local system.
Second Generation:Centralized Version Control Systems
The second generation is the CVS(Centralized Version Control Systems) where the files will be stored in the centralized server for everyone on the team to collaborate. The files are usually stored in repository on the server. You can checkout the files on the working directory.
This version control system works in fully connected manner. And you can keep track of multiple files unlike the first generation. Moreover everyone in the teams knows about what files other people are working on.
Since this system is centralized we have to always work in connected environment and there can be issue if multiple developers have changes in the same file.
Example of CVS are: Perforce, TFS, SVN
Third Generation: Distributed Version Control Systems
Third generation of CVS allowed developers to work on independent workstations. It is like each and every developer working on his own repository.
In this system the developer not just have the latest snapshot of the latest files but all the history of the files copied to his machine.
This VCS allows developer to work in disconnected environment.
Examples: Git, Bitkeeper.
Advantages of Git or DVCS
- Different ways to work with Git or DVCS:
- Centralized
- Developers push changes to one central repository
- Hierarchical
- Developers push changes to subsystem-based repository while working on individual features or fixes
- Once these features or fixes are fully developed they are merged to the main repository.
- Distributed
- Developers push changes to their own repository
- Project maintainers pull changes into official repository. This is very common on open source projects on Github where if you want to contribute you can fork the main repository, make the changes and issue a pull request to project maintainer.
- Centralized
- Other advantage of git is that the backup are very easy. You can easily clone the main repository to the other server.
- Reliable branching/Merging
- Full Local History
About Git
- Created by Linus Torvalds, the creator of Linux
- Development initiated after the separation of Linux-Bitkeeper.
- Started in 2005.
- Written in C and perl
- Supported by majority of the operating system like Windows, Linux, Mac.
- Git goals.
- Simplicity
- Speed
- Strong branch/Merge Support.
- Distributed.
- Scales well for large project.
What is present in Gits Core?
How does git do all these things like having a local copy for each developer. Key value pair is the main principle on which the Git works. No matter what type of file you are working on, the sequence of bytes for that file are the value of the hashmap or dictionary and git generated a SHA1 hash.
The hash is the key for the hashmap for the particular file.
Git calculates the hash using SHA1 algorithm. Each piece of content has its own SHA1 hash.
This is a 40-character string composed of hexadecimal characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git. A SHA-1 hash looks something like this:
24b9da6552252987aa493b52f8696cd6d3b00373
Each and every file, every commit, every folder in Git has its own SHA.
Conclusion:
In this article I have discussed the origin of Git and its advantages. And what is the core principle on which Git is build. All these things can help you to better understand git from the beginner point of view.
Leave a Reply