Git is one an open-source, distributed version controlling system & is used for tracking changes in files/code between multiple peoples/locations. It is the most widely used version controlling system that is being used by millions of users & organizations.

Recommended Read: Install Git on Ubuntu – The Easy Way

Also Read: How to install Java on CentOS & RHEL

It is a distributed system that allows every repository on every system to act as a full-fledged repository itself with complete history & version tracking capabilities. In this tutorial, we will learn to install it on CentOS/RHEL systems. So this tutorial should work for all CentOS/RHEL versions. Here we will be discussing two methods to install git on Linux systems,

1- Using default package manager i.e. yum

2- Using source packages


Install Git on CentOS /RHEL

1- Using default package manager

Git packages are maintained on the default package repositories of CentOS. They might not be the latest packages but they will be stable packages. So to install git on CentOS using yum, we can use the following command,

# yum install git

This would install git on CentOS/RHEL. If for some reason, you need the latest or any particular version of the git, then we recommend that you use the second method for git installation.


2- Using source packages

Now to install git using the source packages, we must have all the required packages for the compilation of git source package. Use the following commands to install the required packages,

# yum install gcc perl-ExtUtils-MakeMaker

# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

Next, we can either download a particular version or can also install the latest git version. We will be installing the latest packages, download the latest packages with the following command,

$ wget https://github.com/git/git/archive/master.zip

The latest packages will always be available at the mentioned URL. Next, we need to unzip the downloaded package,

$ unzip master.zip

$ cd master

Next, compile & install git with the following command,

$ make prefix=/usr/local all

$ sudo make prefix=/usr/local install

This will install git on Linux machine (CentOS or RHEL). Refer to git commands cheat sheet here to learn about git usage & commands. We end this tutorial on how to install git on Linux (CentOS & RHEL). Please do send in any questions, queries or suggestions using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.