YaKun 的头像
YaKun

技术笔记与日常记录

309 字
2 分钟

CentOS7安装Git2.x版本

2021-11-17
2021-12-07

双十一前后又购入了两三台服务器,跟着上次写的一个新的ContOS服务器折腾过程操作一番之后,环境问题基本就解决了,不过在使用某个软件(虽然后来也不用那个了)的时候,被要求安装2.x的Git,但是在CentOs7环境下,Git的最新版本只有1.8.3.1,而Git官方的版本已经更新到2.33.1了,有些软件也需要2.X版本的Git才能支持,所以需要更新。

1.查看当前仓库里的版本信息#

yum search git

当前Git包

2.安装IUS软件源#

查看官方文档,可以看到一段说明如何去更新新版本Git:

Red Hat Enterprise Linux, Oracle Linux, CentOS, Scientific Linux, et al.#

RHEL and derivatives typically ship older versions of git. You can download a tarball and build from source, or use a 3rd-party repository such as the IUS Community Project to obtain a more recent version of git.

前往IUS社区,按照提示安装即可。

yum install \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

3.再次查看当前仓库里的版本信息#

yum search git

安装IUS之后包列表

4.卸载原有Git,如未安装则跳过#

yum remove git -y

5.安装新版本#

yum install git224 -y

6.查看安装结果#

git --version

git安装结果