Install Latest Git ( Git 2.x ) on CentOS

Teddy Zugana
2 min readSep 20, 2021

This guide is for installing the latest release of Git on CentOS 7 server. The git version available on CentOS 7 repository is a bit old, 1.x. If you need a newer version of Git, then use this guide to install it.

Git is a distributed version control system used to track file changes to coordinate work on those files among team members. Git is the most widely used version control system in the world today.

Start by checking installed version of git on your CentOS 7 server.

$ git --version
git version

Install Latest git on CentOS 7 from End Point repository

Endpoint is a community project that provides RPM packages for newer versions of select software for Enterprise Linux distributions. The aim of the project is to create high-quality RPM packages for Red Hat Enterprise Linux (RHEL) and CentOS.

Remove old git

sudo yum -y remove git
sudo yum -y remove git-*

Add End Point CentOS 7 repo

The quickest way of installing the latest version of Git on CentOS 7 is from the End Point repository.

sudo yum -y install

Once repository is added, install Git 2.x on CentOS 7:

sudo yum install git

Hit the y key to accept installation then install git on CentOS 7.

Dependencies Resolved==================================================================================================================================================================
Package Arch Version Repository Size
git x86_64 2.30.1-1.ep7 endpoint 135 k
Installing for dependencies:
emacs-filesystem noarch 1:24.3-23.el7 base 58 k
git-core x86_64 2.30.1-1.ep7 endpoint 4.9 M
git-core-doc noarch 2.30.1-1.ep7 endpoint 2.6 M
pcre2 x86_64 10.23-2.el7 base 201 k
perl-Git noarch 2.30.1-1.ep7 endpoint 52 k
Transaction Summary
Install 1 Package (+5 Dependent packages)
Total download size: 7.9 M
Installed size: 37 M
Is this ok [y/d/N]: y

Check git version after installing git2u-all package

$ git --version
git version 2.30.1

As confirmed, the current version of Git is 2.16.5

Install Latest Git (2.x) from source on CentOS 7

In this method, you’ll be tasked with building git from source code. Install dependency packages required:

sudo yum -y install epel-release
sudo yum -y groupinstall "Development Tools"
sudo yum -y install wget perl-CPAN gettext-devel perl-devel openssl-devel zlib-devel curl-devel expat-devel getopt asciidoc xmlto docbook2X
sudo ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

Download and install latest git:

sudo yum -y install wget
export VER="2.32.0"
tar -xvf v${VER}.tar.gz
rm -f v${VER}.tar.gz
cd git-*
make configure
sudo ./configure --prefix=/usr
sudo make
sudo make install

Check new version of git installed on your system

$ git --version
git version 2.32.0