源码安装git

来源:互联网 发布:linux c http服务器 编辑:程序博客网 时间:2024/05/15 11:51

安装前先确保安装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
原创粉丝点击