1、查询git版本
(1)查看git版本
git --version
(2)如果是1.8.3.1,则是centos默认的git版本,需要先卸载
yum -y remove git
(3)查看git版本,此时应该已经没有git版本了
git --version
2、安装新版本git
(1)安装依赖(如果有依赖,则此步骤跳过)
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc-c++ perl-ExtUtils-MakeMaker
安装完依赖需要重新查询当前git版本,如果有则删除(即重复步骤 1)
(2)下载与安装(git版本可以去官网查看最新稳定版本)
cd /var/local/download
wget https://www.kernel.org/pub/software/scm/git/git-2.28.0.tar.gz
tar -zxvf git-2.28.0.tar.gz
mv git-2.28.0.tar.gz ../software
(3)配置编译安装
cd git-2.28.0/
make configure
./configure --prefix=/usr/local/git
make profix=/usr/local/git
make install
备注:
(1)执行 make configure 提示(/bin/sh: autoconf: command not found)
yum install install autoconf automake libtool
(4)环境变量
vim /etc/profile
export PATH=$PATH:/usr/local/git/bin
source /etc/profile
(5)查看git版本
git --version