Install GIT on RHEL 7.

Install Git Using Yum

Vikash Sharma
2 min readMar 14, 2021

We shall install Git from the system default repositories, and make sure that your system is up-to-date with the latest version of packages by running the Yum update command below and install GIT:

# yum update && yum -y install git

After git successfully installed, you can issue the following command to display the version of Git installed:

# git --version

It is obvious that you will get the older version (1.8.3) of GIT when you using the yum command in RHEL Linux 7 as you are using the default yum repositories. For getting the updated version of GIT you need to install it from the Source.

Installing Git from source code

Before installing Git from source code, make sure you have already installed the required packages on your system. If not use the following command to install the required packages.

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel 
yum install gcc perl-ExtUtils-MakeMaker

Download the latest Git source code from https://github.com/git/git/releases or simply use the following command to download Git 2.30.2.

cd /usr/src 
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.30.2.tar.gz
tar xzf git-2.30.2.tar.gz

After downloading and extracting Git source code, Use the following command to compile the source code.

cd git-2.30.2 
make prefix=/usr/local/git all
make prefix=/usr/local/git install

Step 3 — Setup Environment

After installation of git client. Now you just need to set binary in the system environment. Set the PATH variable with newly installed git binary in /etc/bashrc by executing the below command. Also, reload the changes in the current environment.

echo 'export PATH=/usr/local/git/bin:$PATH' >> /etc/bashrc 
source /etc/bashrc

After completing the steps. Let’s use the following command to check the current git version.

git --version git version 2.30.2

--

--