1.依赖库安装

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker

2.卸载低版本的 Git

yum remove git

3.下载新版的 Git 源码包

直接到GitHub取最新版,现在的最新版是v2.19.1

wget https://github.com/git/git/archive/v2.19.1.tar.gz

4.解压到当前目录

tar xzf v2.19.1.tar.gz

5.安装 Git

cd git-2.19.1
make prefix=/usr/local/git all
make prefix=/usr/local/git install

6.添加到环境变量

echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

7.查看版本号

git --version
05-22 01:25