centos 7.2升级git版本
作者:互联网
问题:在使用“git pull origin master --allow-unrelated-histories”命令时,提示:“error: unknown option `allow-unrelated-histories’”,经过查询发现当前使用的git版本为1.8的版本,git版本较低,因此需要升级git版本.
操作步骤如下:
(1)卸载原有的git软件及其依赖:
[root@cli-1 ~/project]
# yum remove git
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-21.el7_7 will be erased
...
(2)下载最新的git源码:
[root@cli-1 ~/project]
# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.18.1.tar.xz
[root@cli-1 ~/project]
# xz -d git-2.18.1.tar.xz
[root@cli-1 ~/project]
# tar -xvf git-2.18.1.tar
[root@cli-1 ~/project]
# cd git-2.18.1
(3)编译源码:
可能设计到的一些依赖包
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel nss gcc perl-ExtUtils-MakeMaker -y
[root@cli-1 ~/project/git-2.18.1]
# ./configure --prefix=/usr/local/git
[root@cli-1 ~/project/git-2.18.1]
# make
[root@cli-1 ~/project/git-2.18.1]
# make install
(4)修改环境变量,便于命令行直接调用
[root@cli-1 ~/project/git-2.18.1]
# vim /etc/profile
...
#在文件最后添加下面的命令
export PATH=$PATH:/usr/local/git/bin
[root@cli-1 ~/project/git-2.18.1]
# source /etc/profile
(5)检查git版本
[root@cli-1 ~/project/git-2.18.1]
# git --version
git version 2.18.1
daa20
发布了201 篇原创文章 · 获赞 75 · 访问量 29万+
关注
标签:project,git,cli,centos,devel,7.2,2.18,root 来源: https://blog.csdn.net/daa20/article/details/104165307