Linux安装最新版git

时间:2020-12-12 15:23:28
    本文旨在讲述如何在linux上安装最新版的git。1、查看当前git版本:git --version查看最新版git:访问https://www.kernel.org/pub/software/scm/git/或者https://github.com/git/git/releases2、官网下载wget https://Github.com/Git/Git/archive/v2.11.0.tar.gz(建议本机迅雷下载rz到服务器,安装yum install lrzsz后rz即可)解压:tar -zxvf git-2.11.0.tar.gz3、cd git-2.11.04、移除旧版本git:yum remove git5、make configure如果报错/bin/sh: autoconf: command not found:安装libtool即可:yum install install autoconf automake libtool正常会打印:GEN configure执行6、./configure --prefix=/usr/local/git --with-iconv =/usr/local/lib(建议优先尝试后者)或者./configure --prefix=/usr/local/git --with-iconv --with-curl --with-expat=/usr/local/lib(如果没有安装libiconv请自行安装)make && make install①如果报错:cache.h:40:18: fatal error: zlib.h: No such file or directory安装zlib:yum install zlib、yum install zlib-devel②如果报错:make[1]: *** [perl.mak] Error 2安装:yum install perl-ExtUtils-MakeMaker package
7、echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc8、source /etc/bashrc9、git --version
编译git时报错: zlib.h: No such file or directory    缺少 zlib的头文件, 开发包没装,    yum install zlib (系统默认已经装上)    yum install zlib-devel 
git clone时候提示fatal: Unable to find remote helper for 'https'yum install libcurl-devel然后按照上诉步骤重新安装编译git即可