Git提示请求失败
纸上得来终觉浅,绝知此事要躬行。
前几天在 CentOS6 安装 gitlab 工具,在克隆代码的时候,发生报错了。查了很多资料之后,最后才发现是官方自带的 Git 版本太低了导致无法使用的。既然已经有了前车之鉴,所以这里总结一下,出现上述报错的情况下,正确的解决方案和处理思路。
- 【报错信息如下所示】
# 报错信息 fatal: HTTP request failed
- 【原因一】Git 版本过低
# 查看发现CentOS6官方自带的版本太低了 [[email protected] ~]# git --version git version 1.7.4
# git升级的操作记录 # 1.安装依赖软件 [[email protected] ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc [[email protected] ~]# yum install gcc perl-ExtUtils-MakeMaker # 2.卸载系统自带的git版本 [[email protected] ~]# git --version git version 1.7.1 [[email protected] ~]# yum remove git # 3.编译安装最新的git版本 [[email protected] ~]# cd /usr/local/src/ [[email protected] src]# wget https://www.kernel.org/pub/software/scm/git/git-2.17.0.tar.xz [[email protected] src]# tar -vxf git-2.17.0.tar.xz [[email protected] src]# cd git-2.17.0 [[email protected] git-2.17.0]# make prefix=/usr/local/git all [[email protected] git-2.17.0]# make prefix=/usr/local/git install [[email protected] git-2.17.0]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile [[email protected] git-2.17.0]# source /etc/profile # 4.查看升级的git版本信息 [[email protected] ~]# git --version git version git-2.17.0 # 5.如果是非root用户使用git [[email protected] ~]$ echo "export PATH=$PATH:/usr/local/git/bin" >> ~/.bashrc [[email protected] ~]$ source ~/.bashrc [[email protected] ~]$ git --version git version git-2.17.0
- 【原因二】系统的时间不对
# 同步当前时间 [[email protected] ~]# date -s "xxx" # 当然这里也可以用其他方式 [[email protected] ~]# ntpdate xxx.xxx.xxx.xxx
- 【原因三】没有安装 curl 工具
[[email protected] ~]# yum install curl curl-devel