X Chen笔记---Centos升级git版本

原文链接:https://segmentfault.com/a/1190000004563172


有时候使用git命令拉取镜像的时候会失败,除去镜像网址本身就打不开这种情况,很大可能是因为git版本太低。这时候就需要升级git版本。报错格式大体如下:

操作

git clone http://xxxxx.git

报错

error: The requested URL returned error: 401 Unauthorized while accessing http://x.git/info/refs

fatal: HTTP request failed

centos自带的是1.7.1版本,可使用以下命令查看:

git --version


升级过程如下:

先安装依赖

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum install  gcc perl-ExtUtils-MakeMaker   

卸载老版本

yum remove git 

依次执行

wget https://github.com/git/git/archive/v2.2.1.tar.gz
tar zxvf v2.2.1.tar.gz
cd git-2.2.1
make configure
./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
make install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

如果需要的话,那么就

make all doc 
make install install-doc install-html

尝试

git --version

git version 2.2.1


猜你喜欢

转载自blog.csdn.net/chenxin2tj/article/details/79915510
今日推荐