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)下載相應(yī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
下載之后是這樣的,不要感到奇怪,直接解壓即可
下載位置為當(dāng)前目錄
因為下載的是一個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 to
libiconv‘libgit.a(utf8.o): In function reencode_string_len‘:/root/git-2.9.0/utf8.c:502: undefined reference to
libiconv_open‘/root/git-2.9.0/utf8.c:521: undefined reference to libiconv_close‘/root/git-2.9.0/utf8.c:515: undefined reference to
libiconv_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文件
然后而已看到這個文件已經(jīng)有很多配置了,只需要在最下邊添加git的路徑即可:
export PATH=/usr/local/git/bin:$PATH
將這段話放在最后邊,然后使用source命令應(yīng)用修改:
source /etc/profile
3、git的配置(configure)、編譯(make)、安裝(make install)
6、檢驗Git是否安裝成功
git --version