CentOS 编译安装git,解决github HTTPS 403错误

转自: http://www.xuebuyuan.com/2126655.html

  **

CentOS 编译安装git,解决github HTTPS 403错误

**

CentOS 支持yum安装git:

yum install git

但克隆github仓库时:

git clone https://github.com/ironman/ironman.git

提示错误:

error: The requested URL returned error:403 Forbidden while accessing

https://github.com/ironman/ironman.git/info/refs

查阅github文档:https://help.github.com/articles/https-cloning-errors

检查一下:

确定是由于git版本过低导致的,这样就需要从源码编译安装最新的git

先安装一堆依赖包

yum install perl-ExtUtils-MakeMaker gettext-devel expat-devel curl-devel zlib-developenssl-devel openssl-devel gcc-c++ make

然后下载git source:

wget -Ogit-source.tar.gz https://api.github.com/repos/git/git/tarball/master

解压并安装:

tar zxvf git-source.tar.gz
mv git-git* gitsource
cd gitsource

make prefix=/usr install

去官网下载一个libiconvlibiconv:

wget

http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

解压,安装:

tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure–prefix=/soft/lib/libiconv-1.14 (这是libiconv-1.14所在目录)

make
make install

若提示权限不够则在命令前加sudo

回到gitsource目录:

make configure

./configure –-prefix=/usr/local –with-iconv=/soft/lib/libiconv-1.14(这是libiconv-1.14所在目录)

make

make install

此时,git已经编译安装成功

cd /usr/local/bin

./git –version

git version 2.8.0.GIT

卸载通过yum安装的git,

yum remove git

最后,编辑/etc/profile, 将/usr/local/bin加入到系统路径

exportPATH=$PATH:/usr/local/bin

保存退出,再刷新一下系统路径:

source /etc/profile

切换到工作目录,再执行

git –version

如能正确显示版本,

    git version 2.8.0.GIT

则大功告成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值