本文共 842 字,大约阅读时间需要 2 分钟。
原文链接: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/refsfatal: HTTP request failed
centos自带的是1.7.1版本,可使用以下命令查看:
git --version
升级过程如下:
先安装依赖
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidocyum install gcc perl-ExtUtils-MakeMaker
卸载老版本
yum remove git
依次执行
wget https://github.com/git/git/archive/v2.2.1.tar.gztar zxvf v2.2.1.tar.gzcd git-2.2.1make configure./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconvmake installecho "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrcsource /etc/bashrc
如果需要的话,那么就
make all doc make install install-doc install-html
尝试
git --version
git version 2.2.1
转载地址:http://tqwob.baihongyu.com/