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 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 https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
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
======================================================================================================================================================================================================
Updating:
git x86_64 2.36.0-1.ep7 endpoint 70 k
Installing for dependencies:
emacs-filesystem noarch 1:24.3-23.el7 base 58 k
git-core x86_64 2.36.0-1.ep7 endpoint 6.3 M
git-core-doc noarch 2.36.0-1.ep7 endpoint 2.8 M
pcre2 x86_64 10.23-2.el7 base 201 k
Updating for dependencies:
perl-Git noarch 2.36.0-1.ep7 endpoint 45 k
Transaction Summary
======================================================================================================================================================================================================
Install ( 4 Dependent packages)
Upgrade 1 Package (+1 Dependent package)
Total download size: 9.4 M
Is this ok [y/d/N]: y
Check git
version after installing git2u-all
package
$ git --version
git version 2.36.0
As confirmed, the current version of Git is 2.x.y
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 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.36.1"
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.36.1