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 installperl-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

出错了:

LINK git-credential-store

libgit.a(utf8.o): In function `reencode_string_iconv':

/home/chukong/gitsource/utf8.c:530: undefined reference to `libiconv'

libgit.a(utf8.o): In function `reencode_string_len':

/home/chukong/gitsource/utf8.c:569: undefined reference to `libiconv_open'

/home/chukong/gitsource/utf8.c:588: undefined reference to`libiconv_close'

/home/chukong/gitsource/utf8.c:582: undefined reference to `libiconv_open'

collect2: ld ?? 1

make: *** [git-credential-store] Error 1

 

链接时找不到libiconv。去官网下载一个:

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

解压,安装:

tar xzflibiconv-1.14.tar.gz

./configure--prefix=/soft/lib/libiconv-1.14

make

make install

回到gitsource目录:

make configure

./configure –-prefix=/usr/local --with-iconv=/soft/lib/libiconv-1.14

make

make install

 

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

cd /usr/local/bin

./git –version

 git version 1.8.5-rc3

 

卸载通过yum安装的git,

yum remove git

 

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

  exportPATH=$PATH:/usr/local/bin

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

source /etc/profile

 

切换到工作目录,再执行

git –-version

如能正确显示版本,

         git version 1.8.5-rc3

则大功告成

 

运行:

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

输入帐号,密码

Cloning into 'ironman'...

Username for 'https://github.com':

Password for 'https://heliclei@github.com':

就可以从github仓库拉代码了:

remote: Counting objects: 17662, done.

remote: Compressing objects: 100% (7369/7369), done.

Receiving objects: 21% (3861/17662), 3.36 MiB | 31.00 KiB/s

[完]

相关文章
相关标签/搜索