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
1.8.4.3(Latest 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: 1.7.1.0. The minimal supported version is 1.7.1.1. 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 Tools"
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
- Go to https://github.com/git/git and manually click download ZIP button than appears on the right mid of the page. OR
- You can use command line utility wget. Simply type following and execute in consolewget -O git.zip https://github.com/git/git/archive/master.zip
Download the
sources in a separate folder. Your console will look something like
below
Now unzip the .zip
file and navigate to master directory.
unzip git.zip 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 install-html
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 /usr/local/bin/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
- Installing Git on CentOS from sources
- Installing Mercurial on Linux
- How to Install Kdiff3 on Ubuntu
- Pushing from local repository to GitHub hosted remote (SO)
- error: The requested URL returned error: 403 Forbidden while accessing
- Undo the last Git commit?