Git is available in the default repository of centos, so the simplest method is:
$ sudo yum install git
This method is simple, but the version updates in the repository are not timely. For example, the latest version of git in the centos repository is 1.7.1 (today is), but git is officially available in version 2.x.
In this case, you have to use the final kill and compile the source code to install it.
The procedure is as follows:
1. download and install the compilation tool for centos.
$ sudo yum groupinstall “Development Tools”
2. install other Dependencies required for git build or execution.
$ sudo yum install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel
3. Download the source code of the latest version of git.
$ cd ~$ wget -O git.zip https://github.com/git/git/archive/master.zip
4. decompress the source file
$ unzip git.zip$ cd git-master
5. Build and install
$ autoconf$ ./configure$ make && make install
6. Create a link
$ ln -s /usr/local/bin/git /usr/bin/
If the old version has been installed in the system, step 6 May report an error in the file. In this case, delete the old link and re-link it.
7. Check the GIT version
$ git --version
The latest version of git should be displayed.
Install the latest version of Git on centos 6.x