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.
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
cd /usr/local/src
wget https://github.com/git/git/archive/v1.9.5.tar.gz
tar -zxvf git-1.9.5.tar.gz
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.
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