Install Git from source on CentOS

The version of Git available in CentOS 6 is old and doesn’t provide features like Git Subtree etc. You can install RPM Forge to get a newer version, namely 1.8 but that is still pretty old. Therefore this article will explain how to install the latest Git from source.
At the time of writing the latest Git version is 2.2.2 released: 12-Jan-2015.

Instructions to install Git from source on CentOS 6.6 are below:

  1. In order to install Git from source we first need to install some required package dependencies:
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum -y install gcc perl-ExtUtils-MakeMaker
  1. Remove any old Git version if it exists:
yum -y remove git
  1. Download and compile the Git source code:
cd /usr/src
wget https://www.kernel.org/pub/software/scm/git/git-2.2.2.tar.gz
tar xzf git-2.2.2.tar.gz

After you have downloaded and extracted the Git source code you can now install it onto your system with the following commands:

cd git-2.2.2
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc
  1. Now check to see the version of Git installed:
git --version
git version 2.2.2

You can find out more at the Git Getting Started Guide: http://git-scm.com/book/en/v2/Getting-Started-Installing-Git


Subscribe to my feed either by E-mail or by RSS to receive updates as they happen.

Can you improve on any of the tips I’ve discussed here? If you can let me know in the comments.

Jason Edwards