0.linxu下的git安裝

1、安裝依賴
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

注意:perl-ExtUtils-MakeMaker 也是這些安裝列表中的一員,不要因為顯示的換行造成大家認為是兩條執(zhí)行命令。
2、下載git
CentOS6.5自帶的git版本是1.7.1
卸載自帶的git
?

yum remove git

選擇一個目錄,存放下載的git,例如我的是:/home/xuliugen/tmp,大家可以根據(jù)需求到官網(wǎng)下載相應的版本
wget https://github.com/git/git/archive/v2.3.0.zip

wget https://github.com/git/git/archive/v2.13.2.zip
根據(jù)版本更新可以更改 https://github.com/git/git/archive/v2.13.2.zip
3、解壓git
下載之后是這樣的,不要感到奇怪,直接解壓即可

這里寫圖片描述

下載位置為當前目錄
因為下載的是一個zip,所以使用命令將其解壓到git目錄下:
把git源碼包解壓到/usr/local/目錄下 也可以解壓道你要的位置

tar -xzvf git-2.0.0.tar.gz -C /usr/local/

參數(shù)-d 后邊的是解壓到的目錄本地目錄 unzip v2.3.0 -d git

如果沒有此命令需要安裝
yum install zip unzip

4、編譯安裝git
進入git目錄


這里寫圖片描述

將其安裝在“/usr/local/git”目錄下,命令如下:
make prefix=/usr/local/git all make工具則可自動完成編譯工作 sudo make prefix=/usr/local/git install 安裝

編譯時出現(xiàn)如下異常:
libgit.a(utf8.o): In function reencode_string_iconv‘:/root/git-2.9.0/utf8.c:463: undefined reference tolibiconv‘libgit.a(utf8.o): In function reencode_string_len‘:/root/git-2.9.0/utf8.c:502: undefined reference tolibiconv_open‘/root/git-2.9.0/utf8.c:521: undefined reference to libiconv_close‘/root/git-2.9.0/utf8.c:515: undefined reference tolibiconv_open‘collect2: ld 返回 1make: *** [git-credential-store] 錯誤 1

下載并安裝libiconv
cd ..wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gztar -zxvf libiconv-1.14.tar.gzcd libiconv-1.14./configure --prefix=/usr/local/libiconv && make && make install

make configure

./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv 指定 libiconv的安裝位置

繼續(xù)執(zhí)行第4步即可

5、配置Git
sudo vim /etc/profile #編輯profile文件

然后而已看到這個文件已經有很多配置了,只需要在最下邊添加git的路徑即可:
export PATH=/usr/local/git/bin:$PATH

將這段話放在最后邊,然后使用source命令應用修改:
source /etc/profile

3、git的配置(configure)、編譯(make)、安裝(make install)
6、檢驗Git是否安裝成功
git --version

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容