How to Install latest version of Git ( Git 2.x ) on CentOS 7

(: June 26, 2019)

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.{text-align:left} img{margin:0 auto 0 0}
$ git --version
git version

Install the latest git from the IUS repository

IUS 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 remove git*

Add IUS CentOS 7 repo

sudo yum -y install
sudo yum -y install git2u-all

Check git version after installing git2u-all package

$ git --version
git version 2.16.5

As confirmed, the current version of Git is 2.16.5

Install the latest git from source

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

sudo yum groupinstall "Development Tools"
sudo yum -y install wget perl-CPAN gettext-devel perl-devel  openssl-devel  zlib-devel

Download and install git

export VER="2.22.0"
tar -xvf v${VER}.tar.gz
rm -f v${VER}.tar.gz
cd git-*
sudo make install

Check new version of git installed on your system

$ git --version
git version 2.22.0

You should now have the latest release of Git on your CentOS 7 server.{text-align:left} img{margin:0 auto 0 0}