(Last Updated On: March 18, 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.

$ git --version
git version 1.8.3.1

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 install  https://centos7.iuscommunity.org/ius-release.rpm
sudo yum 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 install perl-CPAN gettext-devel perl-devel openssl-devel zlib-devel

Download and install git

export VER="2.21.0"
wget https://github.com/git/git/archive/v${VER}.tar.gz
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.21.0

You should now have the latest release of Git on your CentOS 7 server.