CentOS7 升级 Git 版本

tech2026-03-27  3

目录

文章目录

目录安装依赖包安装 Git

安装依赖包

yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc gcc perl-ExtUtils-MakeMaker tcl xmlto autoconf automake libtool unzip libiconv-1.14.tar.gz wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make && make install

若报错:错误:‘gets’未声明(不在函数内),则需要编辑 libiconv-1.14/srclib/stdio.in.h:

_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); # 改为: #if defined(GLIBC) && !defined(UCLIBC) && !__GLIBC_PREREQ(2, 16) _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); #endif asciidoc wget --no-check-certificate https://jaist.dl.sourceforge.net/project/asciidoc/asciidoc/8.6.9/asciidoc-8.6.9.zip unzip asciidoc-8.6.9.zip cd asciidoc-8.6.9 ./configure nake && make install

安装 Git

wget https://github.com/git/git/archive/v2.2.1.tar.gz tar zxvf v2.2.1.tar.gz cd git-2.2.1 make configure ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv make all doc make install install-doc install-html echo "export PATH=$PATH:/usr/local/git/bin:/usr/local/git/libexec/git-core" >> /etc/bashrc

替换:

mv /usr/bin/git /usr/bin/git-1.8.3.1 ln -s /usr/local/git/bin/git /usr/bin/git git --version
最新回复(0)