ps:由于本人在centos 使用git clone 拉取时 碰见一堆屎,整理了一下网上的经验,分享出来
首先说明本人是阿里的服务器Centos6.5 所以git能安装的最新版本是1.7.1 这时git clone 会出错
# git clone https://git.oschina.net/xxxx/xxxx.git
Initialized empty Git repository in /data/web/xxxx/.git/
error: The requested URL returned error: 401 Unauthorized while accessing
https://git.oschina.net/xxxx/xxxx.git/info/refs
fatal:HTTP request failed
所以我们需要安装新版本的git,现在送上解决方法
-
首先安装依赖库
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
(不安装编译时会报错) -
下载git源码
# cd /usr/src # wget https://www.kernel.org/pub/software/scm/git/git-2.0.5.tar.gz # tar xzf git-2.0.5.tar.gz
-
编译安装
# cd git-2.0.5 # make prefix=/usr/local/git all # make prefix=/usr/local/git install # echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc # source /etc/bashrc
-
检查一下版本号
# git --version
git version 2.0.5
如果git还是提示没有此目录就执行下export PATH=$PATH:/usr/local/git/bin吧
完毕重新clone吧
网友评论