Fork me on GitHub

CentOS7安装更新git的正确打开方式

1

安装centos7 之后一直用自带的git,在提交的时候总是出现下面这种情况,原因是git版本太低导致的,于是就想了办法去更新git,
百度看了很多教程,都是什么先卸载再重新安装,卸载之前还需要备份一份配置文件,看了很多感觉非常麻烦,于是就在Linux网站中看到了一个最正确的更新及安装方式。以下是记录我更新安装过程。

配置存储库

在这之前,我们需要在root权限下才可以进一步操作。
1.启用Wandisco GIT存储库
启用存储库需要在/etc/yum.repos.d/目录中命名的新yum存储库配置文件:

1
vim /etc/yum.repos.d/wandisco-git.repo

添加以下字段,ESC,然后:输入wq保存退出。

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

使用以下命名了导入存储库GPG密钥

1
sudo rpm --import http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco

安装

1
yum install git

完成之后验证一下

1
git --version

输出git version 2.18.0

验证配置文件更改

1
git config --list

输出:

1
2
user.name=Your Name
user.email=youremail@yourdomain.com

配置设置存储在~/.gitconfig文件中:

1
2
3
[user]
name = Your Name
email = youremail@yourdomain.com

要进一步更改Git配置,可以使用git config命令或~/.gitconfig手动编辑文件。

本文标题:CentOS7安装更新git的正确打开方式

文章作者:LiuXiaoKun

发布时间:2019年01月03日 - 16:01

最后更新:2019年01月03日 - 16:01

原始链接:https://LiuZiQiao.github.io/2019/01/03/CentOS7安装更新git的正确打开方式/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

0%