CentOS 6 編譯安裝Git 2.8.1

來源:互聯網
上載者:User

標籤:git 版本控制 gitlab 編譯 源碼 centos 編譯安裝 github 依賴

環境介紹:

系統版本:CentOS 6.4

軟體倉庫:yum-Base,yum-Epel

Git版本:git 2.8.1

安裝方式:源碼編譯



  1. 刪除原yum源中的git 1.7版本

# yum remove git -y


2. 安裝依賴環境

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


3. 下載Git源碼

Git最新版源碼託管在Github: https://github.com/git/git 

# wget -O git_2.8.1.zip # unzip git_2.8.1.zip -d git/


4. 編譯安裝Git

# cd git# cat INSTALL      # 查看安裝說明文檔

由於新版Git源碼安裝不需要 ./configure 步驟,Makefile檔案是直接附帶在源碼檔案中的,所以可以直接 make  和 make install安裝。


但按照安裝說明文檔的話,會預設安裝在/usr 目錄中。 這樣不太利於後期整理和版本升級。

所以我這裡用制定目錄安裝Git 。


查看Makefile檔案,裡面在第415行中定義了安裝的一些路徑。

# make prefix=/usr/local/git mandir=/usr/share/man infodir=/usr/share/info sharedir=/usr/share htmldir=/usr/share/doc/git-doc install install-doc install-info install-html

這樣既把git安裝到了指定目錄,然而man文檔也可以正常查看。 


5. 安裝過程中的一些問題

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/7E/87/wKiom1cDZtWTwRrfAAA7X-gxGHQ708.png" title="16.png" alt="wKiom1cDZtWTwRrfAAA7X-gxGHQ708.png" />

安裝過程中有提示 docbook2x-texi 命令未找到。

該工具需要安裝 docbook2X ,文章前面已經提到。

但是,(總是有個但是650) this.width=650;" src="http://img.baidu.com/hi/jx2/j_0066.gif" alt="j_0066.gif" />)安裝好該包後 仍然提示命令未找到。


我們來看看剛安裝的那個包產生了哪些檔案。 

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M02/7E/84/wKioL1cDaB2wwd7cAAAky86TlOc204.png" title="17.png" alt="wKioL1cDaB2wwd7cAAAky86TlOc204.png" />

紅框的檔案貌似有點奇怪,可能是新版調整了命令路徑吧。

那我們就做個軟串連(障眼法)試試能不能行得通。

# ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi


然後再次編譯安裝。 

這次通過了!  650) this.width=650;" src="http://img.baidu.com/hi/jx2/j_0063.gif" alt="j_0063.gif" />


6. 收尾工作

添加Git路徑到環境變數:

# vim /etc/profile添加一條 export PATH=$PATH:/usr/local/git/bin/儲存退出# source /etc/profile看能否正常運行git# git --version如果不能使用,那麼重新登陸shell 再試就可以了!

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M02/7E/87/wKiom1cDabvDJzd8AAAQhma8uzY917.png" title="16.png" alt="wKiom1cDabvDJzd8AAAQhma8uzY917.png" />



另外,如果經常命令列操作的同學,可以個性定製你的命令列提示符,參考我之前寫的文章:

http://professor.blog.51cto.com/996189/1737500 個性定製你的 Git 命令列提示符


本文出自 “Professor哥” 部落格,請務必保留此出處http://professor.blog.51cto.com/996189/1760455

CentOS 6 編譯安裝Git 2.8.1

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.