Skip to content

Latest commit

 

History

History
161 lines (121 loc) · 5 KB

compile-install-lastest-Git.md

File metadata and controls

161 lines (121 loc) · 5 KB

编译安装最新版 Git

完整步骤

Tips: 为了保证编译一次成功,可以将『遇到的问题』部分中须安装的依赖提前安装好。

获取代码并编译

$ cd ~/workspace/git
$ git clone [email protected]:git/git.git
$ cd git
$ git checkout v2.11.0 ; 当前最新版
$ git checkout -b v2.11 ; 创建新分支
$ make prefix=/usr all doc info
$ sudo mv ../git /opt

卸载旧版 Git

  • yum remove git

将编译好的最新版的目录添加到环境变量

file: ~/.bashrc

PATH=/opt/git:$PATH
export PATH
  • . ~/.bashrc //使环境变量生效
[rainstorm@localhost blog]$ git --version
git version 2.11.0

添加 man-page

添加以下代码到 /etc/man_db.conf 最后一行
MANDATORY_MANPATH                       /opt/git/Documentation

$ cd /opt/git/Documentation
$ mkdir man1 man5 man7
$ mv *.1 man1
$ mv *.5 man5
$ mv *.7 man7

$ man git

后遗症

  1. 在运行命令时可能会出现 no such file... 这类的问题,只要把 /opt/git/ 目录下相应的文件复制到错误指定的位置即可
/usr/libexec/git-core/git-sh-setup: line 343: cd: .git: No such file or directory

$ sudo mkdir /usr/libexec/git-core
$ sudo cp /opt/git/git-sh-setup /usr/libexec/git-core

遇到的问题

git-compat-util.h:280:25: fatal error: openssl/ssl.h: No such file or directory

[rainstorm@localhost git]$ make prefix=/opt/git all doc info
GIT_VERSION = 2.11.0
    * new build flags
    CC credential-store.o
In file included from cache.h:4:0,
                 from credential-store.c:1:
git-compat-util.h:280:25: fatal error: openssl/ssl.h: No such file or directory
 #include <openssl/ssl.h>
                         ^
compilation terminated.
make: *** [credential-store.o] Error 1
  • # yum groupinstall 'Development Tools'

  • # yum install openssl-devel curl-devel expat-devel gettext-devel zlib-devel

Can't locate ExtUtils/MakeMaker.pm in @INC

    SUBDIR perl
/usr/bin/perl Makefile.PL PREFIX='/usr' INSTALL_BASE='' --localedir='/usr/share/locale'
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2

  • # yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

/bin/sh: line 1: asciidoc: command not found

    ASCIIDOC git-show-branch.html
/bin/sh: line 1: asciidoc: command not found
make[1]: *** [git-show-branch.html] Error 127
make[1]: Leaving directory `/home/rainstorm/workspace/git/git/Documentation'
make: *** [doc] Error 2

  • # yum install asciidoc

/bin/sh: line 1: xmlto: command not found

    XMLTO git-show-branch.1
/bin/sh: line 1: xmlto: command not found
make[1]: *** [git-show-branch.1] Error 127
make[1]: Leaving directory `/home/rainstorm/workspace/git/git/Documentation'
make: *** [doc] Error 2

  • # yum install xmlto

/bin/sh: line 1: docbook2x-texi: command not found

    DB2TEXI user-manual.texi
/bin/sh: line 1: docbook2x-texi: command not found
make[1]: *** [user-manual.texi] Error 127
make[1]: Leaving directory `/home/rainstorm/workspace/git/git/Documentation'
make: *** [info] Error 2

  • // 需要 EPEL 源
  • # yum install docbook2X //注意 最后 X 为大写
  • $ cd /usr/bin
  • sudo ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

部分参考

  1. How to install latest version of git in Redhat 6.x/7.x
  2. Can't locate ExtUtils/MakeMaker.pm in @INC 错误的解决方式
  3. How to install latest version of git on CentOS 6.x/7.x