CentOS7系统安装Git
1.安装依赖
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc-c++ perl-ExtUtils-MakeMaker
2.下载git包
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.31.1.tar.gz --no-check-certificate
3.解压到 /usr/local/src 目录下
tar -zxvf git-2.31.1.tar.gz -C /usr/local/src/
4.编译安装
cd /usr/local/src/git-2.31.1/
./configure --prefix=/usr/local/git
make
make install
5.设置环境变量
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
source /etc/profile
6.验证版本号是否正常
git --version
git version 2.31.1
若版本不对,则表示当前git为系统自动带git
可执行:
yum remove git -y
卸载系统自带git
重新执行如下命令更新环境变量
source /etc/profile