1、查看当前版本,然后删除Git

git --version
yum remove git

2、安装依赖

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

3、去官网找打算安装的的Git版本的源码,我下载的是2.73.2版,
官网地址:https://mirrors.edge.kernel.org/pub/software/scm/git/

cd /usr/local/src
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.37.2.tar.gz

4、解压并进入目录

tar -xvf git-2.37.2.tar.gz
cd git-2.37.2

5、编译到指定目录然后安装

make prefix=/usr/local/git all
make prefix=/usr/local/git install

6、设置环境变量,使其立即生效

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

7、查看当前Git版本

git --version

参考文章:https://www.csdn.net/tags/NtDaYg2sMTQ1NC1ibG9n.html

微信截图_20220812162350.png

标签: none

添加新评论