CentOS7自带的GIT 版本有些旧,查看git版本
git --version
git version 1.8.3.1
安装依赖
源代码安装和编译git,需安装一些依赖
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum install gcc perl-ExtUtils-MakeMaker
卸载旧版本
yum remove git
编译安装Git
Git软件包可在此获取: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.23.0.tar.xz
tar -xvf git-2.23.0.tar.xz
cd git-2.23.0/
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
source /etc/profile
验证版本
git --version
git version 2.23.0