Centos7 upgrade git version control tool

Problem Description

The default git installation version of the centos7 system is 1.8, but the git version is found to be too low during the project construction, so I use source code compilation to upgrade. At the same time, this article is also applicable to installing new git, I believe everyone has a certain understanding of git Now, some steps in the article process will not be explained in detail.

Operating environment

centos7.0

Software preparation

git version, libiconv

Installation process

1、 The first step is to uninstall the original git.

yum remove git

2、 Installation related dependencies

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum install  gcc perl-ExtUtils-MakeMaker

3、 Install git

Unzip the compressed package to/usr/local/src directory
tar -C /usr/local/src -vxf git-2.7.3.tar.xz
cd git-2.7.3//Compile
make prefix=/usr/local/git all
//installation
make prefix=/usr/local/git install
//Write to environment variable (Method 1)
echo "export PATH=$PATH:/usr/local/git/bin">>/etc/profile && source /etc/profile
//Write to environment variable(Method Two)export PATH=$PATH:/usr/local/bin/git
//Check whether the installation is successful
git --version

problem solved

The normal process is to install according to the above process. The following summarizes some problems encountered during the installation process. 1. The following error is prompted when compiling with make prefix=/usr/local/git all

LINK git-credential-store
libgit.a(utf8.o): In function`reencode_string_iconv':
/usr/src/git-2.8.3/utf8.c:463: undefined reference to `libiconv'
libgit.a(utf8.o): In function`reencode_string_len':
/usr/src/git-2.8.3/utf8.c:502: undefined reference to `libiconv_open'
/usr/src/git-2.8.3/utf8.c:521: undefined reference to `libiconv_close'
/usr/src/git-2.8.3/utf8.c:515: undefined reference to `libiconv_open'
collect2: ld returned 1 exit status
make:***[git-credential-store] Error 1

This problem is mainly caused by the lack of libiconv library in the system. According to the link provided above, download libiconv.

cd /usr/local/src
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar -zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
Configuration
. /configure --prefix=/usr/local/libiconv
Compile
make
installation
make install
Establish soft connection
ln -s /usr/local/lib/libiconv.so /usr/lib
ln -s /usr/local/lib/libiconv.so.2/usr/lib

At this time, the libiconv library has been installed, enter our git installation directory below, and install it in the following way

make configure
. /configure --prefix=/usr/local --with-iconv=/usr/local/libiconv
Compile
make
installation
make install
Add environment variables
export PATH=$PATH:/usr/local/bin/git
Check the version number
git --version

2、 When installing libiconv, you will encounter the error message ./stdio.h:1010:1: error:'gets' undeclared here (not in a function), you can solve it by following the steps below.

Enter the wrong file path
cd libiconv-1.14/srclib
Edit file stdio.in.h finds line 698, the content is_GL_WARN_ON_USE(gets,"gets is a security hole - use fgets instead");Comment out this line(Note that the annotation must be used/**/To comment), Replace with the following
# ifdefined(__GLIBC__)&&!defined(__UCLIBC__)&&!__GLIBC_PREREQ(2,16)_GL_WARN_ON_USE(gets,"gets is a security hole - use fgets instead");
# endif

Recommended Posts

Centos7 upgrade git version control tool
Centos kernel version upgrade
Manually upgrade node version under CentOs
Manually upgrade node version under CentOs
CentOS7 upgrade python3
Centos6.5 openssh upgrade
Centos7 upgrade kernel
centos6.9 rabbitmq 3.6.8 upgrade 3.8.2
CentOS build private git
Centos 6.4 python 2.6 upgrade to 2.7
CentOS 7.0.1406 official version released
Centos 6.4 python 2.6 upgrade to 2.7
CentOS6.5 upgrade kernel to 3.10.28
View CentOS version information
View CentOS version information
Centos default python2.6 upgrade to
CentOS upgrade python2 to pyth
CentOS8 container management tool Podman
Centos compile and install Git
Centos install high version GCC
Centos6.5 desktop version network settings
centos6.5: gcc upgrade (5.2.0) process record
Centos7 install k8s cluster 1.15.0 version
CentOS 8.0.1905 install ZABBIX4.4 version (verified)
Centos7.6 install MySQL+Redis (latest version)