一、 下载git源码包

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz

二、解压并进入该源码包目录下

三、安装所需依赖包

yum install curl-devel expat-devel gettext-devel   openssl-devel zlib-devel

四、编译安装

./configure --prefix=/usr/local/git --with-curl --with-expat
make && make install

--with-curl --with-expat 解决通过http或https连接远程仓库的需要