Thursday, 21 November 2013

Installing Git on CentOS from sources

Installing Git on your Linux machine is very simple. Simply run sudo yum install git for Fedora/Centos or apt-get install git for Debian based systems or any package management tool you are using.

I am using CentOS Release 6.4 and the reason I am writing this post is that the version of git present in the repository is 1.7.1 whereas current version(as of 21/11/2013) is Stable Release). Thats a huge gap between versions.

Problem I faced was that I checked out HornetQ source from GitHub and then tried to import it in my Intellij IDEA. Project was imported but it failed to index it due to compatibility issues with git version.
Every time I loaded the project I got the following error -

2:53:27 PM Unsupported Git version
           The configured version of
Git is not supported:
           The minimal supported
version is Please update.

So I was left with no option but to download the sources and build it myself. Here is how I did it.

Firstly we need to download some tools needed for compilation and build. Simply execute the following command in your console -

sudo yum groupinstall "Development

For git to build and run we also need dome extra dependencies. To install these dependencies run following on your console

sudo yum install zlib-devel
perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel

Now you will have to download the got source. You can do this in two ways

  1. Go to and manually click download ZIP button than appears on the right mid of the page. OR
  2. You can use command line utility wget. Simply type following and execute in console

  Download the sources in a separate folder. Your console will look something like below

Now unzip the .zip file and navigate to master directory.

cd git-master

Now run the following commands on your console to build and install your latest git.

make configure
./configure --prefix=/usr/local
make all doc
sudo make install install-doc

Note : Generating docs may take some time.

Now you are all set with the latest git version. You can check your version executing following command on your console

git --version

For the sake of logically concluding this post which I wrote because of the problem arising in Itellij IDEA let me explain configuration changes needed in the IDE. Screen shot provided below -

Go to Files->Settings->Version Control->Git

and change the value of Path to Git Executable to /usr/local/bin/git

Where did we get /usr/local/bin/git from?

A natural question that would follow. Answer is simple. When we build our git from sources we provided an argument –prefix=/usr/local after ./configure. You can cross verify this. Simple execute the following in console

which git

This gives the location where git is installed. For me it gives -

[root@localhost aniket]# which git

This path should be same for you unless you give some custom path while building sources. 

For installing git on Windows as well as knowing the basic commands you can refer to following post -

Related Links

t> UA-39527780-1 back to top