How to upgrade git to latest version on CentOS

Updated on February 25, 2022

I’m running git v1.8 on my CentOS 7.8 machine. I would like to upgrade git to the latest version. The command yum install git always tells that v1.8 is already installed and I am unable to proceed further. Below is the snapshot of my server details.

[root@loyalty ~]# yum install git
Package git-1.8.3.1-23.el7_8.x86_64 already installed and latest version
Nothing to do
[root@loyalty ~]# git --version
git version 1.8.3.1
[root@loyalty ~]# more /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

How to upgrade git to the latest version on CentOS

Remove old git

Firstly, you need to remove the older git.

[root@loyalty ~]# yum remove git-*
Removed:
  git.x86_64 0:1.8.3.1-23.el7_8

Dependency Removed:
  gettext-devel.x86_64 0:0.19.8.1-3.el7      intltool.noarch 0:0.50.2-7.el7
  perl-Git.noarch 0:1.8.3.1-23.el7_8

Complete!

Install Repository

Install the IUS Repository which is a 3rd party repository announced on Git’s official site.

[root@loyalty ~]# yum install https://repo.ius.io/ius-release-el7.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@loyalty ~]# yum list git

git.x86_64 1.8.3.1-23.el7_8 base

git222.x86_64 2.22.5-1.el7.ius ius

git224.x86_64 2.24.4-1.el7.ius ius
IUS Repo contains Gitv2.24

However, the IUS repository contains the git version 2.24 and the latest as of now is 2.34!

To install the latest version of git v2.34, you can use another 3rd party repository from endpoint.

[root@loyalty ~]# yum -y install https://packages.endpointdev.com/rhel/7/os/x86_ 64/endpoint-repo.x86_64.rpm
Installed:
  endpoint-repo.x86_64 0:1.10-1

Complete!
[root@loyalty ~]# yum list git
git.x86_64      1.8.3.1-23.el7_8       base
git222.x86_64   2.22.5-1.el7.ius       ius
git224.x86_64   2.24.4-1.el7.ius       ius
git.x86_64      2.34.1-1.ep7           endpoint
Don’t Trust External Repositories!

Here is an article which explains how bad it would be to use external 3rd party repositories. Recommend to use only standard/official repos on a production server. However, if it is a development server and ready to take a bit of risk, try out the 3rd party repos.

Install git

[root@loyalty ~]# yum install git
Installed:
  git.x86_64 0:2.34.1-1.ep7

Dependency Installed:
  git-core.x86_64 0:2.34.1-1.ep7                             git-core-doc.noarch 0:2.34.1-1.ep7                             pcre2.x86_64 0:10.23-2.el7                             perl-Git.noarch 0:2.34.1-1.ep7

Complete!

Verify git version

[root@loyalty ~]# git --version
git version 2.34.1

Was this article helpful?

Related Articles

Leave a Comment