1、依赖安装
yum install dh-autoreconf curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel nss -y
2、移除默认的git
yum remove git -y
3、下载git安装包
https://www.kernel.org/pub/software/scm/git/git-2.39.0.tar.gz
4、安装包上传至/opt/soft
5、解压至/opt/module
tar -zxvf /opt/soft/git-2.39.0.tar.gz -C /opt/module
6、创建安装git的目录
mkdir -p /opt/module/git
7、查看路径
echo $PATH
发现路径中存在anaconda3
/opt/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/usr/local/python3.6/bin/:/root/bin:/opt/jdk/bin
我们在当前终端中临时修改$PATH路径,因为anaconda ,里面包含新版本的 curl 和相关库,并且存在于 PATH 环境变量中,在 ./configure 的时候,会去 anaconda 里面找相关依赖库,而不去系统库找。
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/root/bin:/opt/jdk/bin
8、进入解压目录编译
cd /opt/module/git-2.39.0
./configure --prefix=/opt/module/git
make
make install
9、还原$PATH
export PATH=/opt/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/usr/local/python3.6/bin/:/root/bin:/opt/jdk/bin
10、设置git环境变量
vim /etc/profile
export PATH=$PATH:/opt/module/git/bin/
11、刷新配置
source /etc/profile
12、查看Git版本
git --version
参考地址:https://blog.51cto.com/tchuairen/2407338
标签:bin,opt,git,2.39,Git,usr,Linux,PATH,local From: https://www.cnblogs.com/qq1035807396/p/17057485.html