在 CentOS 6/7 以 yum 安裝 git 2

Luyo
Luyo
Jul 25, 2017 · 2 min read

git 已經可說是現在開發者必備的套件了,但目前 (2017/07/26) CentOS 7.3 的 yum base repository 提供的 git 版本只有到 1.8.3,沒辦法使用 git 2 的一些新功能,例如 git 2.9 新增的 core.hooksPath 的用法,可以讓你不用一定要把 hooks 放在 .git/hooks 裡面,方便大家把 hooks 也加入版本控制,也比較容易設定。

若要安裝 git 2 但不想自己 compile 原始碼,想用 yum 來管理的話,可以使用 IUS 提供的 git2u 套件,安裝方式如下:

  1. 若本來已有安裝 git,須先將之移除:
$ sudo yum remove git

2. 安裝 epel-release repository 以免找不到必要的相依套件:

$ sudo yum install epel-release

3. 安裝 IUS repository (for RHEL/CentOS 7):

$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm 

4. 安裝 git2u:

$ sudo yum install git2u

以上指令引用這個問答裡的內容。

另外,若你使用 CentOS 6 有同樣的需求,只要把第 3 步網址裡的 centos7 改成 centos 6 即可。

verybuy-dev

VeryBuy 研發手札

Luyo

Written by

Luyo

Founder, Developer of VeryBuy — https://www.verybuy.cc

verybuy-dev

VeryBuy 研發手札

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade