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

install latest git centos 7

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 Latest git on CentOS 7 / RHEL 7 from YUM 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 / RHEL 7 repo

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

sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm

Once repository is added, install Git 2.x:

sudo yum install git

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

....
Transaction Summary
======================================================================================================================================================================================================
Install  1 Package (+33 Dependent packages)

Total download size: 25 M
Installed size: 82 M
Is this ok [y/d/N]: y

Check git version after installing git2u-all package

$ git --version
git version 2.41.0

As confirmed, the current version of Git is 2.x.y

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

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

sudo yum -y remove git*
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 curl
export VER="v2.41.0"
wget https://github.com/git/git/archive/${VER}.tar.gz
tar -xvf ${VER}.tar.gz
rm -f ${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.41.0

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

Recommended Linux Books  to read:


3 COMMENTS

  1. All the git files appear to be in my home directory. It would help to specify the directory where to install it, and/or how to move the files after install.

LEAVE A REPLY

Please enter your comment!
Please enter your name here