1、如果有旧版本,删除git
rpm -qa|grep git
rpm -e --nodeps git 或者 rpm -e git
2、下载依赖包
yum install gcc
yum install gcc-c++
yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
3、下载源码包
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.22.0.tar.xz
4、配置安装
xz -d git-2.22.0.tar.xz
tar -xvf git-2.22.0.tar
cd git-2.22.0
make prefix=/opt/software/git-2.22.0 all
make prefix=/opt/software/git-2.22.0 install
4、设置环境变量
vim /etc/profile
export PATH=/opt/software/git-2.22.0:/opt/software/git-2.22.0/bin:/opt/software/git-2.22.0/libexec/git-core:$PATH
source /etc/profile
git --version