转自: 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
则大功告成