CentOS 7 安装 Git 2.x 版本

  • 原创
  • Madman
  • /
  • /
  • 0
  • 11655 次阅读

install-latest-git-centos-7-1024x386.png

Synopsis: CentOS 7 安装 Git >= 2 版本,因为用 VSCode 进行远程开发时,总是提示远端 CentOS 上的 Git 版本(1.8.3.1)过低,建议升级到 2.x 版本

相关链接:

CentOS 7 用自带的源安装 Git 版本比较老:

[root@CentOS ~]# git --version
git version 1.8.3.1

在安装新版本前,我们需要删除旧版本:

[root@CentOS ~]# yum -y remove git

1. 通过第三方源安装

1. 添加源
[root@CentOS ~]# yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.9-1.x86_64.rpm

2. 安装 Git 2.x
[root@CentOS ~]# yum -y install git

3. 验证
[root@CentOS ~]# git --version
git version 2.30.1

2. 手动下载 RPM 包

https://packages.endpointdev.com/rhel/7/os/x86_64/ 下载对应版本的几个包到本地,比如:

git-2.30.1-1.ep7.x86_64.rpm
git-core-2.30.1-1.ep7.x86_64.rpm
git-core-doc-2.30.1-1.ep7.noarch.rpm
perl-Git-2.30.1-1.ep7.noarch.rpm

再执行 yum install -y *.rpm 即可

3. 通过源码编译安装

可以访问 https://github.com/git/git/releases 或者 https://mirrors.edge.kernel.org/pub/software/scm/git/ 下载 最新版本 的源代码

参考: https://github.com/git/git/blob/master/INSTALL

1. 准备编译环境
[root@CentOS ~]# yum -y groupinstall "Development Tools"
[root@CentOS ~]# yum -y install perl-CPAN gettext-devel perl-devel openssl-devel zlib-devel

2. 下载源代码
[root@CentOS ~]# wget https://github.com/git/git/archive/v2.22.0.tar.gz

3. 解压
[root@CentOS ~]# tar xf v2.22.0.tar.gz
[root@CentOS ~]# cd git-2.22.0/

4. 编译、安装
[root@CentOS git-2.22.0]# make prefix=/usr && make install

5. 验证
[root@CentOS git-2.22.0]# git --version
git version 2.22.0
分类: Linux
标签: IUS Github Kernel Git CentOS
未经允许不得转载: LIFE & SHARE - 王颜公子 » CentOS 7 安装 Git 2.x 版本

分享

作者

作者头像

Madman

如需 Linux / Python 相关问题付费解答,请按如下方式联系我

0 条评论

暂时还没有评论.

专题系列

文章目录