Centos下安裝git高版本2.1.2


安裝依賴軟件

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

卸載系統自帶的底版本git(1.7.1)

# git --version git version 1.7.1 # yum remove git

編譯安裝最新的git版本

鏈接:https://pan.baidu.com/s/1YnhtIN4ZJmbcv4ohQ81Evg 密碼:hgd4 //百度雲下載地址,下載好放到/usr/local/src
cd /usr/local/src/ # tar -vxf git-2.1.2.tar # cd git-2.1.2 # make prefix=/usr/local/git all # make prefix=/usr/local/git install # echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile # source /etc/profile # git --version git version git-2.1.2

======================================================================
如果是非root用戶使用git,則需要配置下該用戶下的環境變量

$ echo "export PATH=$PATH:/usr/local/git/bin" >> ~/.bashrc $ source ~/.bashrc $ git --version git version git-2.1.2

 

可能遇到報錯:utf8.c:463: undefined reference to `libiconv'

 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

解決如下:

一.安裝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
# ./configure --prefix=/usr/local/libiconv && make && make install

二.創建一個軟鏈接到/usr/lib

# ln -s /usr/local/lib/libiconv.so /usr/lib
# ln -s /usr/local/lib/libiconv.so.2 /usr/lib

三.然后回到git目錄繼續編譯

# cd /usr/local/scr/git-2.8.3
# make configure
# ./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv
# make
# make install

四.檢查一下版本號

# git --version

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM