How to Install Latest Git 1.8+ on CentOS 6 When Yum Only Provides Older Versions


3 views

When working with CentOS 6, you might encounter a frustrating situation where the default yum repositories only offer Git 1.7.1, while the official Git website lists version 1.8+ as current. This isn't because your system is misconfigured - CentOS deliberately maintains older, stable versions in its default repos.

Red Hat-based distributions like CentOS prioritize stability over cutting-edge versions. The package maintainers thoroughly test specific versions before including them in official repositories. Here's what you're seeing:

# yum info git
Installed Packages
Name        : git
Arch        : x86_64
Version     : 1.7.1
Release     : 2.el6_0.1

The easiest way to get newer Git versions is by adding the EPEL (Extra Packages for Enterprise Linux) repository:

# For CentOS 6
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# Then install Git
sudo yum install git

For even newer versions, consider the IUS repo which specializes in newer versions of common tools:

sudo rpm -Uvh https://centos6.iuscommunity.org/ius-release.rpm
sudo yum install git2u

When you absolutely need the latest version, compiling from source gives you complete control:

# Install dependencies
sudo yum groupinstall "Development Tools"
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

# Download and compile
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.30.0.tar.gz
tar -zxf git-2.30.0.tar.gz
cd git-2.30.0
make prefix=/usr/local all
sudo make prefix=/usr/local install

After any installation method, verify your Git version:

git --version
# Should show version 1.8+ depending on method used

For development environments where you need to test against different Git versions, consider using git-wrapper:

sudo yum install git-all
git --version=2.30.0
git --version=1.8.5

Remember that compiling from source means you'll need to manually update Git in the future, while using repositories allows for easier updates through yum.


When working with CentOS 6, you might encounter package version limitations due to the conservative nature of enterprise Linux distributions. While git-scm.com advertises version 1.8+ for modern systems, running:

yum install git

Returns:

Package git-1.7.1-2.el6_0.1.x86_64 already installed and latest version
Nothing to do

This discrepancy occurs because Red Hat/CentOS backports security fixes to older versions rather than providing the newest upstream releases.

Here are three reliable ways to obtain newer Git versions on CentOS 6:

1. Using IUS Community Repository

First import the IUS repository which provides newer packages:

sudo yum install https://centos6.iuscommunity.org/ius-release.rpm
sudo rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
sudo yum install git2u

This will install Git 2.x while maintaining system stability.

2. Building from Source

For maximum version control (though more complex):

sudo yum groupinstall "Development Tools"
sudo yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
wget https://www.kernel.org/pub/software/scm/git/git-2.30.0.tar.gz
tar -zxf git-2.30.0.tar.gz
cd git-2.30.0
make configure
./configure --prefix=/usr/local
make all
sudo make install

3. Using Software Collections (SCL)

Red Hat's SCL provides newer versions while maintaining system stability:

sudo yum install centos-release-scl
sudo yum install rh-git29
scl enable rh-git29 bash

After installation, always verify:

git --version

For source builds or SCL installations, you may need to adjust your PATH if the binary isn't found.

Enterprise distributions prioritize stability over new features. The git-1.7.1 package in CentOS 6 receives backported security patches, making it "latest" from the distribution's perspective. This differs from upstream's definition of "latest."