Build and Install git from source on CentOS 6

CentOS 6 comes with a packaged version of git that can easily be installed using yum install git however it's a bit old and you may run into issues with newer repo's where you see this error

The requested URL returned error: 401 Unauthorized while accessing

If this happens you most likely need a newer version of git.

Installing git from source

The following instructions will help you build and install a newer version of git. In this article we will be building version 2.9.5 and will be installing it into /opt/git

yum -y install gcc zlib-devel gettext curl libcurl libcurl-devel perl-ExtUtils-MakeMaker
cd /usr/src
tar xvf git-2.9.5.tar.xz
cd git-2.9.5
./configure --prefix=/opt/git && make && make install

Using the new version of git

Since we installed git in /opt/git you will need to call it directly at /opt/git/bin/git.