参考:https://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git
Git 的工作需要调用 curl,zlib,openssl,expat,libiconv 等库的代码,所以需要先安装这些依赖工具。
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel $ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
之后,从下面的Git 官方站点下载最新版本源代码:
http://git-scm.com/download
然后编译并安装:
$ tar -zxf git-1.7.2.2.tar.gz $ cd git-1.7.2.2 $ make prefix=/usr/local all $ sudo make prefix=/usr/local install
编译如果出现错误:
usr/bin/perl Makefile.PL PREFIX=‘/usr/local/git‘ INSTALL_BASE=‘‘ --localedir=‘/usr/local/git/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-MakeMaker
安装完成后git命令的位置在/usr/local/bin下面,如果输入git --version 命令,出现bash: /usr/bin/git: No such file or directory 错误,则在/etc/profile中添加bin目录到PATH环境变量中。
时间: 2024-10-19 06:25:11