杜老师习惯使用 Git 工具管理代码,最近因为工作所需,要在 CentOS7 服务器上安装 Git 工具,但在使用时出现了一些问题,最终发现因 Git 版本导致,那么就说说如何升级 Git 版本。
版本查询
1 2
| [root@localhost ~]# git --version git version 1.8.3.1
|
注意:杜老师服务器的 Git 是通过 yum 安装,使用命令查询目前版本。
尝试升级
1 2 3 4 5 6 7
| [root@localhost ~]# yum update git 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.bfsu.edu.cn * extras: mirrors.bfsu.edu.cn * updates: mirrors.bfsu.edu.cn No packages marked for update
|
注意:杜老师首先想到的是使用 yum update 更新,结果事与原违,并没有版本的更新。
解决思路
在网上提供的升级方案,其本上都是先删除原来版本,然后在官网上下载最新版本,最后编译安装。编辑安装不仅麻烦,而且容易出错,无意中在网上看到一个 Git 软件源,在此分享一下使用方法:
1
| vim /etc/yum.repos.d/wandisco-git.repo
|
首先输入上门命令新建配置文件,在配置文件中输入下面内容:
1 2 3 4 5 6
| [wandisco-git] name=Wandisco GIT Repository baseurl=http://opensource.wandisco.com/centos/7/git/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
|
因为开启了 gpgcheck,所以需导入 key 文件:
1
| rpm --import http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
|
导入成功后即可进行 Git 升级:
验证版本
1 2
| [root@localhost ~]# git --version git version 2.31.1
|
注意:版本升级成功。不过杜老师在升级前查询了官网最新版本是 2.35.1,看来该软件源并非最新版本。
条评论