Centos compile and install Git

There are two ways to install Git on centos, one is through source installation, and the one-click installation can be successful through the following command:

yum -y install git

However, the highest version of Git installed through source is currently 1.7. If you want to use more new features and updated version of Git, you can only install it by compiling and installing. The following is a specific introduction to this installation process.

1、 Install the dependency package first
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
2、 Download the Git source code package and unzip it
cd /usr/local/src
wget https://github.com/git/git/archive/v1.9.5.tar.gz
tar -zxvf git-1.9.5.tar.gz
3、 Compile and install
cd git-1.9.5
make configure
. /configure --prefix=/usr/local/--with-iconv=/usr/local/libiconv/
make && make install

During the installation process, the following errors may appear:

LINK git-credential-store 
libgit.a(utf8.o): In function`reencode_string_iconv': 
/opt/git-master/utf8.c:530: undefined reference to `libiconv' 
libgit.a(utf8.o): In function`reencode_string_len': 
/opt/git-master/utf8.c:569: undefined reference to `libiconv_open' 
/opt/git-master/utf8.c:588: undefined reference to `libiconv_close' 
/opt/git-master/utf8.c:582: undefined reference to `libiconv_open' 
collect2:ld returns 1
make:***[git-credential-store]Error 1

Analyze the cause of the problem is that the libiconv extension package cannot be found, and it can be solved by packaging the libiconv package:

cd /usr/local/src
# Please do not download the updated version of libiconv package, 1.Version 14 is sufficient,
# Otherwise, when running Git, "/usr/local/bin/git: undefined symbol: locale_charset" error
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

After libiconv is successfully installed, switch back to the git directory:

cd /usr/loca/src/git-1.9.5

Then re-execute "Step 3", and Git is basically installed.

4、 View Git version
git --version

Check the Git version by the above command, but the system prompts:

bash:/usr/bin/git: No such file or directory

It means that there is no Git execution program in the "/usr/bin/" directory.
Find the directory of Git execution program by command:

which git

Found that the directory of the Git execution program is:

/usr/local/bin/git

Use the following command to establish a soft link with the "/usr/bin/" directory:

sudo ln -s /usr/local/bin/git /usr/bin/git

Check the next version:

git --version

As shown in the figure below, Git is completely installed successfully!

https://www.marser.cn/tag/26.html

Recommended Posts

Centos compile and install Git
CentOs7.3 compile and install Nginx 1.9.9
Centos7 compile and install ntp-4.2.8p11
CentOS 6.9 compile and install python
CentOS 6 compile and install python 3
CentOS Yum compile and install MySQL 5.6
Compile and install LAMP under Centos 5.2
CentOS 8 install Git and basic configuration
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
Linux CentOS6 compile and install Pyt
Install centos7 and connect
Compile and install libmodbus library under CentOS7
CentOS7.5 source code compile and install mysql5.7.29
Centos7 compile and install MySQL8 problem record
Compile and install nodejs and yum in Centos8
CentOS7.4 source code compile and install MySQL8.0
Centos6.5 compile and install LNMP architecture web environment
Centos7.2 compile and install way to build phpMyAdmin
centos7 install python3 and ipython
Know Linux and install CentOS
CentOS 7 install Mono and MonoDevelop
Ubuntu 16.04 compile and install PHP 7.2
CentOS6.5 install Java 8 and Tomcat8
Centos6.5 install and configure mongodb
CentOS7 install python3 and pip3
CentOS7 install OracleJDK and JRE
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack Jira 7
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack confluence
CentOS6 install and crack Jira 7
Centos compile and install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis
1.5 Install Centos7
Compile and install Lnmp shell script under Linux centos
Centos 7 install jdk and package service service
CentOS7 yum install and start mysql
Install and configure keepalived under CentOS 5.9
How to install Git on CentOS 8
CentOS7.3 install iptables and detailed use
CentOS quickly install Python3 and pip3
CentOS7 yum install and start mysql
CentOS 8 - install and configure NFS service
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Centos7 uninstall openJdk, and install JDK1.8
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
CentOS7 install and use SQL Server
CentOS Minimal install and configure TIPS
CentOS 7 install gogs git code server
Install Python3 and Py under CentOS7
Install and configure FreeIPA in Centos7
Compile and install QEMU under Ubuntu
virtualBox install centos, and build tomcat
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Centos6 install Python2.7.13
CentOS8 deploys LNMP environment to compile and install mysql8.0.29 tutorial details
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
CentOS install Redmine
Centos7 install Python 3.6.