文章目录

  • 查看系统相关信息
    • 查看CentOS的版本号
    • 查看内核版本
    • 查看 git 版本
  • 通过安装第三方 yum 源的方式来更新git
    • 下载对应的 yum 源
    • 安装 yum 源
    • 删除掉已经存在的 git
    • 安装 ius 源中的 git
  • 后记

查看系统相关信息

查看CentOS的版本号

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

查看内核版本

[root@localhost ~]# uname -r
3.10.0-693.el7.x86_64

查看 git 版本

[root@localhost haskell]# git version
git 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, replace
Loading 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, replace
Loading 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 version
git version 2.16.5

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

后记

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

centos 7 升级 git 版本(通过安装 ius 源的方式)相关推荐

  1. Centos下升级git版本

    1.升级原因 在使用git pull.git push.git clone的时候,或者在使用jenkins发版的时候,可能会报类似如下的错误: error: The requested URL ret ...

  2. Centos6 升级Git版本

    Centos 6 升级Git版本 Centos 6自带Git版本1.7.1,无法满足项目需求,故升级至最新Git版本. 1.删除现有版本Git yum remove git 2.安装编译git时所需要 ...

  3. Centos(Linux)升级git最新版本

    在Linux/Centos服务器上,如果使用的git版本过低,使用的时候可能会由于低版本不支持遇到各种问题,比如Centos7系统自带的git版本一般是1.8.3.1的,比较旧,通常建议升级git后再 ...

  4. centos下升级g++版本

    转载请注明文章出处:https://juejin.im/post/5d0ef5376fb9a07ef63fe74e CentOS 7官方源带的gcc最新版本是4.8.5,发布于2015年,年代久远且不 ...

  5. Centos7安装IUS源

    Centos7安装IUS源 安装IUS源 配置IUS国内源 刷新缓存 Centos7使用yum安装git224版本 卸载老版git 查询源里的git版本号 安装git224 查看git版本 安装IUS ...

  6. centos7升级gcc版本,无需手动下载源码编译

    centos7升级gcc版本,无需手动下载源码编译 第一步: 安装centos-release-scl 第二步: 安装devtoolset 第三步: 激活对应的devtoolset 第四步: 查看版本 ...

  7. centos上升级node_在centos7安装nodejs并升级nodejs到最新版本

    1. 安装nodejs 1.1 使用EPEL安装 EPEL(Extra Packages for Enterprise Linux)企业版Linux的额外软件包,是Fedora小组维护的一个软件仓库项 ...

  8. linux 升级 git版本,CentOS下升级Git1.7.1升级到Git2.2.1

    卸载CentOS自带的Git 通过git –-version查看系统带的版本,Cento6.5自带的是git版本是1.7.1yum remove git 安装前环境配置$ yum install -y ...

  9. gzinflate php cetnos,Centos 6.5升级git版本的办法

    安装依赖: yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc yum install ...

最新文章

  1. zabbix 之 orabbix安装指导
  2. 如果产品经理去卖土豆粉
  3. python3 实现 A+B Problem(百练OJ:1000)
  4. 巧用Environment.UserInteractive 实现开发和生产环境的分开调试部署
  5. 基础正则表达式介绍与练习
  6. 分支和循环结构的应用(习题)
  7. 图的最小生成树(Prim算法)
  8. cisco交换机MAC/CAW***防范
  9. Codeforces Round #479 (Div. 3) F. Consecutive Subsequence (简单dp)
  10. 计算机考研专业课王道,王道论坛,专注于计算机考研的点点滴滴!
  11. 数据集加载--load_digits
  12. 实施工程师的发展前景
  13. Atitit 高性能架构法艾提拉著作 目录 1. 前期可以立即使用的技术 2 2. 分离法 3 2.1. Web db分离 3 2.2. 读写分离 4 2.3. CDN加速技术 4 2.4. 动静分
  14. 移动光猫固件备份、刷机、改sn和mac等
  15. Authentication—身份验证流程
  16. mysql中工作表工作簿的查询_如何使用SQL语句实现对Excel工作表数据的查询?
  17. 上海数据分析师面试经历
  18. 【PP那些事儿】生产模式-面向订单生产
  19. python获取pdf页面尺寸_python-从pdf提取页面作为jpeg
  20. moment的常见应用

热门文章

  1. 志宇-RabbitMQ学习
  2. 苹果结构体系不匹配_iPhone 5C下载安装微信时提示结构不匹配怎么办及 iPhoneX怎么强制重启...
  3. MYSQL 基于抖音上MYSQL开发工程师面试,如果是你怎么样
  4. 物联网 FOTA升级的必要性
  5. 书单来了!大厂的技术牛人在读什么:字节跳动篇
  6. of介词短语作定语_介词短语做后置定语的用法
  7. GPS数据矢量化JAVA_SVGX矢量化图形编辑器,100%JAVA实现的矢量化图形编辑器
  8. 网站域名备案工信部短信核验流程讲解
  9. 服务端高并发分布式架构演进之路(阿里巴巴90秒100亿)
  10. 音乐类编曲软件——水果FL Studio的入门小知识