Hello World!
In this blog let us see what is git and how it is used in industry.
Git is a Distributed Version Control System (DVCS), that holds the whole history of project, including the changes. It is built with security, performance and flexibility in mind. It was developed in 2005 by Linus Torvalds the famous creator of Linux kernel.
A system that records changes to a file or set of files over time is called a Version Control System. This enables us to recall a specific version later.
Some of previous version control tools:
As I said earlier, git is a Distributed Version Control System. Let us quickly look into DVCS and other previous VCS.
Local Versioning System (LVS): A database that stores different versions of files. Its main drawback is that we cannot collaborate with other team member. Everything is local.
Centralized Version control System (CVS): Here all the versioned files are stored in a centralized server. The members of team can checkout the files from the server. There were certain degree of possibilities to know what other members in the project are doing. Its drawback is every thing is stored in the centralized server. When server crashes, everything is gone. We cannot also work when server is down. Saving entire history of project in a single place is a high risk.
Distributed Version Control System (DVCS): In DVCS, unlike the other VCS, the whole project including history is mirrored into the client’s device. So even when the centralized server crashes, we can revamped from the client’s clone. This enables us to collaborate with different group of people in a different way, simultaneously.
Like Git we have other DVCS like Mercurial, Bazzar, Darcs. Let us see how Git stands out from these DVCS.
Let’s dive technically into git.
There are three states in git
Linux:
$sudo dnf install git-all (For RPM based distributions)
$sudo apt install git-all (For Debian, Ubuntu distributions)
Mac:
$git — version
If git is not installed, it will prompt to install.
Windows:
Follow this link: https://git-scm.com/download/win
Git config
Get and set configuration variables that controls all aspects of how git looks and operates
Global Configuration
Here we will be configuring things like username, email, etc
git config — global user.name “sriram23”
git config — global user.email <your email>
Any directory that has a ‘.git’ directory in it are called git repository. The ‘.git’ directory will have the complete history of the project.
Creating a git repo
I will create a new directory and make it as a git repository.
$mkdir myFirstGitRepo
$cd myFirstGitRepo
$git init
This will create a directory called myFirstGitRepo and once git init command is executed, a .git directory will be created.
Cloning an existing repo
We can clone an existing remote repo (we will see about the remote repo in upcoming chapters). We can do it by using the git clone command.
git clone “https://github.com/sriram23/Battery-Tracker.git”
To summarize, in this blog, we learned about Git, VCS and its history, Git installation and Git repo. In the upcoming blogs, we will explore more about git.
Thank you!