What is git ?
April 3rd 2020 1283
In the previous tutorial we have learned and understand what Github is and about its interface and how to use it. In this tutorial we will learn about Git and what is a version control system. So let's get started.
What is git?
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning-fast performance. Git was initially designed and developed by Linus Torvalds for Linux kernel development. This tutorial explains how to use Git for project version control in a distributed environment.
So let's see what do we mean by version control system.
Version Control System
Version Control System (VCS) is a software that helps software developers to work together and maintain a complete history of their work.
Listed below are the functions of a VCS −
- It allows developers to work simultaneously.
- Maintains a history of every version.
- It does not allow overwriting each other’s changes.
Following are the types of VCS −
- Centralized version control system (CVCS).
- Distributed/Decentralized version control system (DVCS).
Centralized Version Control
Centralized version control systems are based on the idea that there is a single “central” copy of your project somewhere (probably on a server), and programmers will “commit” their changes to this central copy. There are quite a lot of tools available to meet this need, including Perforce, Mercurial, SVN are examples of centralized version control.
Distributed Version Control System
A centralized version control system (CVCS) uses a central server to store all files and enables team collaboration. But the major drawback of CVCS is its single point of failure, i.e., failure of the central server. Unfortunately, if the central server goes down for an hour, then during that hour, no one can collaborate at all. And even in a worst-case, if the disk of the central server gets corrupted and proper backup has not been taken, then you will lose the entire history of the project. Here, a distributed version control system (DVCS) comes into the picture.
DVCS clients not only check out the latest snapshot of the directory but they also fully mirror the repository. If the server goes down, then the repository from any client can be copied back to the server to restore it. Every checkout is a full backup of the repository. Git does not rely on the central server and that is why you can perform many operations when you are offline. You can commit changes, create branches, view logs, and perform other operations when you are offline. You require a network connection only to publish your changes and take the latest changes.
Distributed model: This means your work is your own. You can let others see only what is necessary. Not everything has to be public. There are other advantages to the distributed model, such as the speed (since most everything is local) and possibility of working offline
Branching and merging are easy: Branching is a walk in the park. It feels like a natural part of the workflow. They are cheap (fast and consume very little space) so that you can branch whenever you want. This means you can sandbox your features and ideas till they are ready for the mainstream.
Workflow is flexible: Compared to Centralized VCS, git has the qualities that allow you to choose your own workflow.
Data integrity is assured: Because git uses SHA1 trees, data corruption due to external reasons can be easily detected.
Security: Git uses a common cryptographic hash function called secure hash function (SHA1), to name and identify objects within its database. Every file and commit is check-summed and retrieved by its checksum at the time of checkout. It implies that it is impossible to change file, date, and commit message and any other data from the Git database without knowing Git.
Icing on the cake:
Fast: Git is very fast, even when compared to other DVCS, for local as well as network operations
Staging area: Make sure your commits have logically grouped changes and not everything else you are working on.
Free: I am sure you don't want to spend 450$ for your personal project. Your manager will appreciate it if you save him N x 450$
- Steep learning curve: Many commands with many options, some commands are non-intuitive and need a level of understanding the internals of git, commands and arguments are inconsistent to some degree
- Binary files are a big no: If your project has non-text files that are updated frequently (images for websites or MS Office documents), then git becomes bloated and slow. (I believe it still does better than most systems)
That’s it!! In the next tutorial, we will see how to install and configure git on your system.