How to Install Git 1.9.0 on CentOS 6.4 (Compiling from Source) March 24, 2014Posted by Tournas Dimitrios in Uncategorized.
Git is an open source, distributed version control system developed by Linus Torvalds , the creator of the Linux kernel . Git allows a team of people to work together, all using a copy of files from a central repository , and when they have made their own contribution on the code , committing the changes back to the central repository . This helps the team cope with the confusion that tends to happen when multiple people are editing the same files . A characteristic example where Git is used for , is the Linux kernel , with 3500 contributors and 15 million lines of code . Although Git is an excellent tool for managing large , complex projects with tens or even hundreds contributors , it can also be used on small projects with one developer or a small team . This flexibility makes it a great choice for implementing version and source control for software projects of any size .
There are countless Git client tools on the market , GUI or terminal based , commercial or free . Without doubt , the most adopted client tool for Git is terminal based (which happen to be named “git”) . Two reasons that made this tool the primary choice by the majority of the software development community are flexibility and cross-platform compatibility . Software developers that use the Windows platform are lucky here , they just download the latest version of the git-client and run the installation script (an “.exe” file) . In contrast , software developers that have chosen a *nix like platform for their development are “trapped” to use a version of git that their official repository provides . And usually , the officially supported repositories linger to adopt the latest version of the tools they support . That might sound unimportant at first , and usually it is . But there are cases where a newer version of a “package” has a feature that we really need . The official supported repository of CentOs 6.4 provides a “git” version that is quite a bit outdated .While many developers use only git’s basic functionality and don’t care about the officially provided version , others though , have the need to use all available features that this tool provides .
Probably you could compile even newer version of git from the source . However, the purpose of this article is to show how to install the latest stable version of git available in the repositories . We won’t need to remove the officially supported git client from our machine , as both versions can coexist on the same box and used interchangeably . To compile the source code (which won’t take more than five minutes) , we must have the following tools pre-installed on our machine : lib-curl-devel , expat-devel , openssl-devel , zlib-devel and gcc . Here are the steps to follow :
- open a terminal
- yum list installed |egrep -wi ‘libcurl-devel|expat-devel|openssl-devel|zlib-devel|gcc’ #verify that the required tools are installed
- cd /tmp
- mkdir git ; cd git
- tar xzfv git-1.9.0.tar.gz
- cd git-1.9.0/
- sudo make prefix=/usr/local all
- sudo make prefix=/usr/local install
- cd ../.. ; rm -fR git
- # now restart your terminal
- which git # /usr/local/bin/git
- git –version #git version 1.9.0
- /usr/bin/git –version #git version 1.7.1
Both versions are now installed on our machine . The compiled version is installed on /usr/local/bin directory and the version of the officially supported repository was installed on /usr/bin directory . Because /usr/local/bin has precedence in terminal’s $PATH variable , this version of git will be used as default . We can “force” the terminal to use the git version installed by our officially supported repository by explicitly calling the tool (/usr/bin/git) . The steps followed on my terminal while compiling/installing git were recorded and can be viewed on showterm.io .
Happy coding , keep yourself healthy and don’t hesitate to drop a message on the comment section below .