日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

centos7 安装Git

發布時間:2023/11/28 生活经验 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos7 安装Git 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝git前先檢查一下是否有舊版本git

通過git –version查看系統帶的版本,如果有就刪除

# yum remove git

1.安裝依賴的包

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install ?gcc perl-ExtUtils-MakeMaker
2.下載git源碼并解壓

wget https://github.com/git/git/archive/v2.3.0.zip
unzip v2.3.0.zip(或:unzip v2.3.0)
進入解壓的目錄

cd git-2.3.0
3.編譯安裝

安裝在/usr/local/下

make prefix=/usr/local/git all
make prefix=/usr/local/git install

 編譯時出現如下異常:

libgit.a(utf8.o): In function `reencode_string_iconv':
/root/git-2.3.0/utf8.c:463: undefined reference to `libiconv'
libgit.a(utf8.o): In function `reencode_string_len':
/root/git-2.3.0/utf8.c:502: undefined reference to `libiconv_open'
/root/git-2.3.0/utf8.c:521: undefined reference to `libiconv_close'
/root/git-2.3.0/utf8.c:515: undefined reference to `libiconv_open'
collect2: ld 返回 1
make: *** [git-credential-store] 錯誤 1

  下載并安裝libiconv

cd ..
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

  返回git在此編譯安裝

cd ../git-2.3.0
make clean
autoconf
./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv/
make install

錯誤如下:

    In file included from progname.c:26:0:./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");^make[2]: *** [progname.o] Error 1make[2]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'make[1]: *** [all] Error 2make[1]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'make: *** [all] Error 2

?

解決辦法:

vi libiconv-1.14/srclib/stdio.in.h

將698行的代碼:_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

此時執行git --version仍然提示command not found,git已經安裝成功,可能是配有配置環境變量

4.配置環境變量

vim /etc/profile
在文件最后一行添加:export PATH=/usr/local/git/bin:$PATH,保存退出

發現仍然不行,這是因為配置還未生效,不重啟系統,使用source命令立即生效

source /etc/profile
然后git --version,提示 git version 2.3.0,已安裝成功。

我這是用一個新linux服務器安裝的,所有步驟都以列出,如有問題請聯系

總結

以上是生活随笔為你收集整理的centos7 安装Git的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。