How to install the latest version of Git on CentOS 7.x/6.x?

Installing the latest version of Git on CentOS can be accomplished through multiple approaches. CentOS repositories often contain older versions of Git, so these methods help you install more recent versions with enhanced features and security updates.

Approach 1: Using IUS Community Repository

The IUS Community Repository provides updated packages for Enterprise Linux distributions. This is the most straightforward method for getting a recent Git version.

Commands

yum install epel-release
yum remove git
rpm -U https://centos7.iuscommunity.org/ius-release.rpm
yum install git2u
git --version

Output

immukul@192 lib % git --version
git version 2.29.2

Approach 2: Compiling from Source

This method involves downloading and compiling Git from source code, giving you complete control over the version and compilation options. It requires installing development tools first.

Commands

yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
export GIT_VERSION=2.29.2
mkdir /root/git
cd /root/git
wget "https://www.kernel.org/pub/software/scm/git/git-2.29.2.tar.gz"
tar xvzf "git-2.29.2.tar.gz"
cd git-2.29.2
make prefix=/usr/local all
make prefix=/usr/local install
yum remove -y git
git --version

Output

immukul@192 git-2.29.2 % git --version
git version 2.29.2

Approach 3: Using EndPoint Repository

The EndPoint Repository provides another source for updated Git packages on Enterprise Linux systems, offering a simpler installation process than compiling from source.

Commands

sudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
sudo yum install git
git --version

Output

immukul@192 git-2.29.2 % git --version
git version 2.29.2

Comparison of Approaches

Approach Complexity Control Update Method Best For
IUS Repository Low Medium Package manager Most users
Source Compilation High Full Manual recompilation Advanced users
EndPoint Repository Low Medium Package manager Enterprise environments

Key Points

  • Remove existing Git − All approaches remove the default CentOS Git package to avoid conflicts.

  • Development dependencies − Source compilation requires additional development packages and libraries.

  • Version flexibility − Source compilation allows you to install any specific Git version by changing the download URL.

  • Repository maintenance − Third-party repositories may require periodic updates to their GPG keys.

Conclusion

All three approaches successfully install recent Git versions on CentOS systems. The IUS Community Repository offers the best balance of simplicity and currency for most users, while source compilation provides maximum flexibility for specific requirements.

Updated on: 2026-03-17T09:01:38+05:30

954 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements