系统: Centos
由于系统自带的yum源仓库的git版本较低,所以在官网下载源码进行编译安装
官网地址:https://git-scm.com/
 源码下载地址:https://github.com/git/git
-  安装旧版本的git拉去git源码(如果是上传到服务器就不用了下载git了) [root@localhost ~]# yum -y install git
-  拉取git源码 [root@localhost ~]# git clone https://github.com/git/git.git
-  安装可能需要的依赖 [root@localhost ~]# yum -y install curl-devel expat-devel openssl-devel zlib-devel gcc-c++ [root@localhost ~]# yum -y install perl-ExtUtils-MakeMaker automake autoconf libtool make
-  编译安装 [root@localhost ~]# cd git/ [root@localhost git]# ./configure --prefix=/usr/local/git # 安装在/usr/local目录下 [root@localhost git]# make && make install
-  卸载旧的git并将新安装的git设置环境变量 [root@localhost ~]# yum -y remove git [root@localhost ~]# echo 'export GIT_HOME=/usr/local/git' >> /etc/profile [root@localhost ~]# echo 'export PATH=$PATH:$GIT_HOME/bin' >> /etc/profile
-  加载配置文件,并查看git版本 [root@localhost ~]# source /etc/profile [root@localhost ~]# git versiongit version 2.43.0