查看已有版本的git

[cuianbing@book08 ~]$ git --version
git version 1.8.3.1

安装依赖库

[cuianbing@book08 ~]$ yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

下载源码,进行编译

到github上下载源码,下载地址

  • 尽量不要选择rc版本
  • 尽量选择最新版本低3-4个版本的
  • 我这里选择2.33.0这个版本,复制右下角tar.gz的链接地址

Centos编译安装新版本Git

[cuianbing@book08 ~]$ wget https://github.com/git/git/archive/refs/tags/v2.33.0.tar.gz  # 下载安装包
[cuianbing@book08 ~]$ tar -zxvf v2.33.0.tar.gz   # 解压安装包
[cuianbing@book08 ~]$ cd git-2.33.0/  # 切换到源码目录
[cuianbing@book08 ~]$ make prefix=/usr/local/git all  # 编译
[cuianbing@book08 ~]$ make prefix=/usr/local/git install # 安装
[cuianbing@book08 ~]$ echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc  # 配置环境变量
[cuianbing@book08 ~]$ source /etc/bashrc  # 更新环境变量
[cuianbing@book08 ~]$ yum remove -y git # 卸载老版本的git
[cuianbing@book08 ~]$ git --version  # 查看git版本
git version 2.33.0

相关文章:

  • 2021-08-14
  • 2021-05-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2021-05-29
  • 2022-12-23
  • 2021-08-06
相关资源
相似解决方案