打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
centos 7 升级 git 版本(通过安装 ius 源的方式)

文章目录

  • 查看系统相关信息

    • 查看CentOS的版本号

    • 查看内核版本

    • 查看 git 版本

  • 通过安装第三方 yum 源的方式来更新git

    • 下载对应的 yum 源

    • 安装 yum 源

    • 删除掉已经存在的 git

    • 安装 ius 源中的 git

  • 后记

查看系统相关信息

查看CentOS的版本号

[root@localhost ~]# cat /etc/centos-releaseCentOS Linux release 7.4.1708 (Core) 

查看内核版本

[root@localhost ~]# uname -r3.10.0-693.el7.x86_64

查看 git 版本

[root@localhost haskell]# git versiongit version 1.8.3.1

可以看到,我的 CentOS 7 中自带的是 1.8.3.1 版本的git,我想升级到最新版本,于是我进入了git官网,去找我该怎么升级我的git版本。

进入相关下载页面(https://git-scm.com/download/linux) 可以看到以下信息:


我们可以看到,我们使用的 Red Hat 有两种升级我们 git 版本的方式,分别是:

  1. 源码编译安装的方式

  2. 用第三方 yum 源,来更新我们的 git 版本

通过安装第三方 yum 源的方式来更新git

下载对应的 yum 源

我们点击进入 the IUS Community Project 网站,首页是这样的:


可以看到,这个页面很友好,很干净。简单的介绍了一下项目用途,项目哲学,介绍了以下怎么使用。

然后我们可以点击下图中的这个链接,进入对应的页面:


这里为了方便直接,我直接在这里放出页面地址:https://ius.io/GettingStarted/

点进去以后,找到下面这一段:


用我四级的水平稍微理解了一下,可以明白,我么们用的 CentOS 系统,可以跳过安装 epel-release ,直接进入第二步了。

然后我们就能回到我们的 Linux,通过 wget 下载对应版本的 rpm 源。

[root@localhost ~]# wget https://centos7.iuscommunity.org/ius-release.rpm--2018-11-07 09:29:06--  https://centos7.iuscommunity.org/ius-release.rpm正在解析主机 centos7.iuscommunity.org (centos7.iuscommunity.org)... 162.242.221.48, 2001:4802:7801:102:be76:4eff:fe21:14aa正在连接 centos7.iuscommunity.org (centos7.iuscommunity.org)|162.242.221.48|:443... 已连接。已发出 HTTP 请求,正在等待回应... 301 Moved Permanently位置:https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-15.ius.centos7.noarch.rpm [跟随至新的 URL]--2018-11-07 09:29:11--  https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-15.ius.centos7.noarch.rpm正在解析主机 dl.iuscommunity.org (dl.iuscommunity.org)... 146.20.25.47, 2001:4802:7901:0:4ccc:ff11:0:a正在连接 dl.iuscommunity.org (dl.iuscommunity.org)|146.20.25.47|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:8340 (8.1K) [application/x-redhat-package-manager]正在保存至: “ius-release.rpm”100%[================================================================>] 8,340       --.-K/s 用时 0s      2018-11-07 09:29:15 (95.7 MB/s) - 已保存 “ius-release.rpm” [8340/8340])

如果你还没有安装 wget,那么这里安利一下我之前写过的一篇安装 python3 的文章,https://blog.csdn.net/lovefengruoqing/article/details/79284573,里面有安装 wget 的教程,希望能帮到你。

安装 yum 源

[root@localhost ~]# rpm -i ius-release.rpm 警告:ius-release.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 9cd4953f: NOKEY

删除掉已经存在的 git

如果不删除,直接安装,会报错:

[root@localhost ~]# yum install git2u已加载插件:fastestmirror, langpacks, replaceLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * ius: hkg.mirror.rackspace.com * updates: mirrors.aliyun.com正在解决依赖关系--> 正在检查事务---> 软件包 git2u.x86_64.0.2.16.5-1.ius.centos7 将被 安装--> 正在处理依赖关系 git2u-core = 2.16.5-1.ius.centos7,它被软件包 git2u-2.16.5-1.ius.centos7.x86_64 需要--> 正在处理依赖关系 git2u-core-doc = 2.16.5-1.ius.centos7,它被软件包 git2u-2.16.5-1.ius.centos7.x86_64 需要--> 正在处理依赖关系 git2u-perl-Git = 2.16.5-1.ius.centos7,它被软件包 git2u-2.16.5-1.ius.centos7.x86_64 需要--> 正在检查事务---> 软件包 git2u-core.x86_64.0.2.16.5-1.ius.centos7 将被 安装---> 软件包 git2u-core-doc.noarch.0.2.16.5-1.ius.centos7 将被 安装---> 软件包 git2u-perl-Git.noarch.0.2.16.5-1.ius.centos7 将被 安装--> 处理 git2u-core-2.16.5-1.ius.centos7.x86_64 与 git-core < 2.16.5 的冲突--> 处理 git2u-perl-Git-2.16.5-1.ius.centos7.noarch 与 perl-Git < 2.16.5 的冲突--> 处理 git2u-2.16.5-1.ius.centos7.x86_64 与 git < 2.16.5 的冲突--> 解决依赖关系完成错误:git2u-perl-Git conflicts with perl-Git-1.8.3.1-14.el7_5.noarch错误:git2u conflicts with git-1.8.3.1-14.el7_5.x86_64错误:git2u-core conflicts with git-1.8.3.1-14.el7_5.x86_64 您可以尝试添加 --skip-broken 选项来解决该问题 您可以尝试执行:rpm -Va --nofiles --nodigest

这里需要注意的是,使用ius源安装的软件,一般都会在软件名称后面加上版本号u,我们查询一下就能知道:

[root@localhost ~]# yum info git*u --disablerepo=base,extras,updates --enablerepo=ius已加载插件:fastestmirror, langpacks, replaceLoading mirror speeds from cached hostfile * epel: mirrors.aliyun.com * ius: mirrors.tuna.tsinghua.edu.cn已安装的软件包名称    :git2u架构    :x86_64版本    :2.16.5发布    :1.ius.centos7大小    :2.3 M源    :installed来自源:ius简介    : Fast Version Control System网址    :https://git-scm.com协议    : GPLv2描述    : Git is a fast, scalable, distributed revision control system with an         : unusually rich command set that provides both high-level operations         : and full access to internals.         :          : The git rpm installs common set of tools which are usually using with         : small amount of dependencies. To install all git packages, including         : tools for integrating with other SCMs, install the git-all meta-package.

通过查询得知,在 ius 源中有 2.16.5 版本的 git,这已经比我们系统自带的 1.8.3.1 版本的 git 好多了。

删除掉原本的版本的 git:

yum remove git

安装 ius 源中的 git

安装命令为:

yum install git2u 

安装完成以后检查一下版本:

[root@localhost ~]# git versiongit version 2.16.5

恭喜你,你已经成功通过 ius 源,安装了新版本的 git 了。

后记

至于通过源码编译的方式安装 git,我之前写过一篇类似的文章,地址为:https://lovefengruoqing.github.io/blog/CentOS下git最新版本的安装方法.html ,顺便安利一下我用 hexo 搭建的个人博客吧。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
centos x86
git: command not found
CentOS下yum找不到安装软件的解决方法。
centos 7 搭建wordpress 网站详细教程
VMware虚拟机安装CentOS 7并搭建Lamp服务器环境
centos5下两种方法安装git
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服