This brief guide explains what is Git, benefits of using Git, how it works, what is GitHub and how to install Git in Linux operating systems.
What is Git?
Git is a a popular distributed source control system or version control system used to track changes in the files or in source code of a project.
Git is an open source tool developed by Linus Torvalds in 2005 for the development of Linux Kernel source code. It is completely free to use and released under GNU General Public License Version 2.
Using Git, we can easily track changes in any set of files like who has changed the code, what has been changed and when has been changed etc. The changes can be shared with a remote repository.
Git is usually used for coordinating work among programmers collaboratively developing source code during software development. It doesn’t require any central system and most of the operations are local.
The developers can see the changes of each others, add new features, resolve issues together and also see the history of entire project as they build the application.
All the project's files as well as the history of changes made to those files are stored in a folder named Repository. Usually, a Git repository is consists of files, history, config managed by git.
Every project under the distributed version control system Git, goes through four stages. The four stages of Git are:
- Working directory,
- Staging area: pre-commit holding area,
- Local repository,
- Remote repository (GitHub, GitLab, BitBucket, TFS etc).
The following graphical illustration explains how Git works:
We will discuss each stage in detail when we learn about Git basics in the upcoming articles.
What is GitHub?
There are many hosting platforms allows you to host your Git repositories. GitHub is one of them.
GitHub is the most popular hosting platform for software development and version control using Git.
With the help of GitHub, one or more developers can work on a same project and also collaborate with other developers for different projects from anywhere in the World.
There are tens of thousands of projects are hosted in GitHub. It offers both free and paid plan. GitHub is owned by Microsoft corporation.
The other notable similar hosting platforms are GitLab, BitBucket, and AWS CodeCommit. Of course there are many hosting platforms exists. But these are well known platforms for remote hosting Git repositories.
Install Git On Linux
Git is available in the default repositories of most Linux distributions.
Install Git in Alpine Linux:
$ sudo apk add git
Arch Linux:
$ sudo pacman -S git
Debian, Ubuntu, Linux mint, Pop_OS!:
$ sudo apt install git
Fedora, RHEL, CentOS, AlmaLinux and Rocky Linux:
$ sudo dnf install git
openSUSE:
$ sudo zypper install git
Once installed, you can check the version of Git using command:
$ git --version git version 2.31.1
As you can see in the above output, I have installed Git version 2.31.1.
In our upcoming tutorials, we will look into Git Fundamentals in more details.
Resource: