1. 官网下载安装包
https://www.kernel.org/pub/software/scm/git/git-2.34.1.tar.gz
2. 解压安装包
tar -zxvf git-2.34.1.tar.gz
3. 卸载之前
yum remove git
4. 安装编译环境
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
5. 编译源码
进入刚刚解压的git文件夹中
make prefix=/opt/module/git all
prefix里面填你想要放的文件夹位置
6. 安装git
make prefix=/opt/git install
7. 配置环境变量
vim /etc/profile.d/my_env.sh
export GIT_HOME=/opt/module/git
export PATH=$GIT_HOME/bin:$PATH
刷新配置文件
source /etc/profile