Linux(centos) 環境下如何源碼編譯安裝git的教程

來源:互聯網
上載者:User

最近線上要使用git進行代碼發布和版本管理了,之前搞過,一直沒有做記錄。從今兒起開始記錄這塊。

linux上(當前文章使用的是centos,ubuntu採用apt-get這裡不細說)安裝git有兩個辦法:yum安裝和source編譯,不建議yum。 yum都是老版本的,建議去github上下載源碼編譯安裝。這裡記錄下步驟:

1,安裝依賴包。

源碼編譯之前,先安裝一些依賴:

yum install  perl cpio curl curl-devel  zlib-devel openssl-develexpat-devel  gettex-devel -y

2,下載並編譯安裝。

源碼下載地址:https://github.com/git/git/releases
這裡我們以當前最新版本https://github.com/git/git/archive/v2.11.0-rc1.tar.gz 為例操作。

wget https://github.com/git/git/archive/v2.11.0-rc1.tar.gz
tar zxvf  v2.11.0-rc1.tar.gz
cd git-2.11.0-rc1/
make configure  #注意這一步,預設無法直接進行./configure,不存在configure檔案,需要執行這一步。
./configure   --prefix=/usr/local/git
make
make install

安裝完畢。

3,設定環境變數。

編譯安裝完以後git命令無法直接使用,需要設定下環境變數。執行如下操作:

echo "export PATH=/usr/local/git/bin:$PATH" >> /etc/profile
source  /etc/profile

好了,現在就可以直接使用了。查看效果:

[root@21yunwei git-2.11.0-rc1]# git --version
git version 2.11.0-rc0

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.