卸载旧版本Git

$ yum remove -y git 

下载Git源码包

$ wget --no-check-certificate https://www.kernel.org/pub/software/scm/git/git-2.36.2.tar.gz

安装依赖包

$ yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel
$ yum install -y gcc perl-ExtUtils-MakeMaker
<h1 id="解决 SSL connect error">解决 SSL connect error</h1>
<p>$ yum update -y nss curl libcurl

编译安装新版本Git

# 解压缩软件包
$ tar -zxvf git-2.36.2.tar.gz
$ cd git-2.36.2</p>
<h1 id="创建要安装的目录">创建要安装的目录</h1>
<p>$ mkdir -p  /usr/local/git</p>
<h1 id="编译安装">编译安装</h1>
<p>$ ./configure --prefix=/usr/local/git
$ make && make install

添加环境变量

# 添加环境变量
$ echo -e "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile.d/git.sh</p>
<h1 id="使新加的环境变量生效">使新加的环境变量生效</h1>
<p>$ source /etc/profile.d/git.sh</p>
<h1 id="验证是否配置成功">验证是否配置成功</h1>
<p>$ git --version
git version 2.36.2