查看当前Git版本一般Centos自带的是1.7.1
git --version
1、安装编译工具
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc gcc perl-ExtUtils-MakeMaker xmlto
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
tar zxvf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=/usr/local/libiconv-1.15 --enable-static
make && make install
ln -s /usr/local/libiconv-1.15 /usr/local/libiconv
2、卸载Centos自带的git1.7.1:
yum remove git
3、下载git2.14.1并将git添加到环境变量中
wget https://www.kernel.org/pub/software/scm/git/git-2.14.1.tar.gz
tar zxvf git-2.14.1
cd git-2.14.1
./configure --prefix=/usr/local/git-2.14.1 --with-iconv=/usr/local/libiconv
make all doc
make install install-doc install-html
ln -s /usr/local/git-2.14.1 /usr/local/git
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc
4、查看版本号
git --version