如何安装git

之前通过yum安装git,没有发现git的源码安装方式原来这么多坑,依赖比较多,不过网上教程也很多。

安装方式一:yum安装

# 下载yum源
curl -Lo ius-release-el7.rpm https://repo.ius.io/ius-release-el7.rpm
yum -y install ius-release-el7.rpm
# 安装git
#yum -y install git224
注意这个源里面git版本会更新。现在已经变成git236了
yum install git236

# 检查git版本
git version

安装方式二:git源码安装

1. 下载源码包

地址:

Index of /pub/software/scm/git/

或: https://github.com/git/git   

2. 源码安装

2.1 只安装git工具,不按照git文档(推荐,git文档的安装依赖特别多)

make configure
./configure --prefix=/usr # 配置目录
make && make install

2.2 安装git的同时,安装git文档

make configure
./configure --prefix=/usr
make all doc info
make install install-doc install-html install-info

2.3 依赖安装

#不安装git文档时的依赖
yum install -y curl-devel zlib-devel gcc autoconf 

#安装git文档时的依赖
yum install -y curl-devel perl-XML-SAX.noarch texinfo perl openjade dh-autoreconf autoconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto docbook2x

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/d/docbook2X-0.8.8-17.el7.x86_64.rpm
rpm -ivh docbook2X-0.8.8-17.el7.x86_64.rpm 
ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

2.4 安装过程中遇到的问题(前面安装的依赖就是根据这些问题整理出来的)

GIT_VERSION = 2.24.4
    GEN configure
/bin/sh: autoconf: command not found
make: *** [configure] Error 127

解决方法(安装autoconf) : yum install install autoconf automake libtool

    * new build flags
    CC fuzz-commit-graph.o
In file included from commit-graph.h:7:0,
                 from fuzz-commit-graph.c:1:
cache.h:21:18: fatal error: zlib.h: No such file or directory
 #include
                  ^
compilation terminated.

解决方法(安装zlib-devel): yum install zlib-devel

    * new asciidoc flags
    ASCIIDOC git-init-db.html
/bin/sh: line 1: asciidoc: command not found

 解决方法(安装asciidoc): 

yum install -y asciidoc
如果yum安装方式不行,可以使用源码安装
wget --no-check-certificate https://jaist.dl.sourceforge.net/project/asciidoc/asciidoc/8.                                                                                6.9/asciidoc-8.6.9.zip
tar zxf asciidoc-8.6.9.tar.gz
cd asciidoc-8.6.9/
./configure
make && make install

/bin/sh: line 1: xmlto: command not found
make[1]: *** [git-init-db.1] Error 127

 解决方法(安装xmlto):yum -y install xmlto

    DB2TEXI user-manual.texi
/bin/sh: line 1: docbook2x-texi: command not found
make[1]: *** [user-manual.texi] Error 127

安装docbook2x-texi

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/d/docbook2X-0.8.8-17.el7                                                                                .x86_64.rpm
# 安装docbook2X
rpm -ivh docbook2X-0.8.8-17.el7.x86_64.rpm

会报错:
warning: docbook2X-0.8.8-17.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
error: Failed dependencies:
        /usr/bin/sgml2xml is needed by docbook2X-0.8.8-17.el7.x86_64
        openjade is needed by docbook2X-0.8.8-17.el7.x86_64
        perl(XML::SAX::ParserFactory) is needed by docbook2X-0.8.8-17.el7.x86_64
        texinfo is needed by docbook2X-0.8.8-17.el7.x86_64


需要安装相应的依赖:
yum install -y texinfo perl openjade
yum install -y perl-XML-SAX.noarch

#创建链接:
ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

以上这些都是安装过程中遇到的依赖,每次出现问题被中断后,可以去装需要的依赖,再重新回来执行安装命令直到成功。

你可能感兴趣的:(git,git,linux,github)