一、从Githup 下载 git源码

wget https://codeload.github.com/git/git/zip/master
mv master master.zip 再解压

二、安装

手册: 
https://github.com/git/git/blob/master/INSTALL

2.1 安装准备--把依赖包都装上

yum install tk zlib-devel openssl-devel perl cpio expat-devel gettext-devel search perl-devel xmlto

2.2 安装asciidoc包

wget https://jaist.dl.sourceforge.net/project/asciidoc/asciidoc/8.6.9/asciidoc-8.6.9.zip
./configure --prefix=/usr/local/git/asciidoc
make && make install

2.3 编译安装GIT

make ./configure
./configure --prefix=/usr/local/git
make install install-doc install-html

2.4 查看是否成功

/usr/local/git/bin/git --version 
git version 2.13.GIT

2.6 为方便使用,直接创建软连

ln -s /usr/local/git/bin/* /usr/bin/

三、遇到问题记录
3.1
/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/share/locale'
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2
解决:

看提示是perl的问题,用yum search perl,出来好大一堆,yum search perl-devel,这下好了,执行yum -y install perl-devel,然后继续再make && make install就可以了. 

3.2
po/bg.msg make[1]: *** [po/bg.msg] Error 127
解决:

yum install tk zlib-devel openssl-devel perl cpio expat-devel gettext-devel

3.3
/bin/sh: line 1: asciidoc: command not found
make[1]: *** [git-add.html] Error 127
make[1]: Leaving directory `/opt/git-master/Documentation'
make: *** [doc] Error 2
解决:

wget https://jaist.dl.sourceforge.net/project/asciidoc/asciidoc/8.6.9/asciidoc-8.6.9.zip

3.4
/bin/sh: line 1: xmlto: command not found
解决:

yum install xmlto

四、发育良好的程序包

https://share.weiyun.com/e3c904dffad5c3726e0d16afc08f19a9
进入包内直接执行 sh install.sh 即可