源码安装git

安装前先确保安装libcurl-devel,否则安装git后有些命令会用不了。如clone命令会提示fatal: Unable to find remote helper for 'https'

系统为centos6.7 x64,可以直接用yum安装git,安装后发现版本太低1.7,决定重新安装

因为已安装git,git的源码放在github上,可以直接用git克隆下来

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

下载后进入git目录

cd git

生成configure文件

make configure

设置安装目录

./configure --prefix=/usr/local

编译文档

make all doc

这个命令可能会出错,因为有依赖的包可能没安装,我的系统安装的时候是以最小化安装的,所以很多包都缺失,安装下面几个包,根据主机环境而定

yum install perl-ExtUtils-MakeMaker tcl gettext-devel asciidoc xmlto

安装完成后再执行make all doc,如果出现如下结果则成功

root@localhost git]# make all doc
    SUBDIR git-gui
    SUBDIR gitk-git
    SUBDIR perl
    SUBDIR templates
make -C Documentation all
make[1]: Entering directory `/root/git/Documentation'
make[2]: Entering directory `/root/git'
make[2]: “GIT-VERSION-FILE”是最新的。
make[2]: Leaving directory `/root/git'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/git/Documentation'

安装软件和文档

make install install-doc install-html


之前用yum安装的git是在/usr目录中,现在我们安装在/usr/local中,执行git --version还是老版本的git,可以先卸载老版本,然后做一个链接。

如果新版本的安装目录也是/usr,则新版本会覆盖老版本,不用执行下面的命令

卸载老版本

rpm -e perl-Git git

ln -s /usr/local/bin/git /usr/bin/git

[root@localhost ~]# git --version
git version 2.9.0


安装完成


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值