How to install Git on CentOS

Git is a free and open source distributed version control system. In this article, we will demonstrate how to install Git on a CentOS  server.

First of all we need to make sure that we have set up needed packages on our system. Use following command to set up needed packages before obtaining Git resource.

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install  gcc perl-ExtUtils-MakeMaker

Now eliminate any prior set up of Git through RPM file or Yum program. If your older version is also compiled through resource, then miss this step.

yum remove git

Use the following command to download Git 2.0.5.

cd /usr/src
wget https://www.kernel.org/pub/software/scm/git/git-2.0.5.tar.gz
tar xzf git-2.0.5.tar.gz

Now use following command to compile source code.

cd git-2.0.5
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

Now Git will be successfully installed on your system,Use the following command to check Git version:

git --version

git version 2.0.5