make Git on CentOS 5.6

Git 是個很棒的分散式版本控制系統,在 Debian, Ubuntu 只需一行指令就可無痛安裝,而 CentOS 的套件庫似乎還未收錄到 Git,這對開始使用 Git 管理機器的凍仁有些意外,只要預裝一下 gcc 自己編就搞定了!

1. 下載 git-$VERSION.tar.gz (本文使用的版本為。

2. 解壓縮。
root@CentOS:~$ tar zxvf git- [Enter]

3. 切換至 git-$VERSION 目錄底下。
root@CentOS:~$ cd git- [Enter]

4. 設定編譯環境 (自訂安裝目錄為 /usr/local/git)。
root@CentOS:~$ ./configure --prefix=/usr/local/git [Enter]

5. 編譯。
root@CentOS:~$ make && make install [Enter]

6. 將 git 執行檔連結至 /usr/local/bin/。
root@CentOS:~$ ln -s /usr/local/git/bin/git* /usr/local/bin/ [Enter]

7. 測試。
root@CentOS:~$ git [Enter]
usage: git [--version] [--exec-path[=]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=] [--work-tree=] [--namespace=]
           [-c name=value] [--help]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and merge with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

See 'git help ' for more information on a specific command.

恭喜您,現在可以在 CentOS 上使用 git 了,是不是很棒啊!

# 近來在下啟用了減重大作戰,相對的整理筆記的時間也少了,不過能在第一週就瘦了 3.5kg 真的是很開心呢,紀錄一下囉!


在編譯 Git 之前還需從安裝光碟補完 curlcurl-devel 兩套件,而安裝 curl-devel 時得一同補上其相依套件 (e2fsprogs-devel, keyutils-libs-devel, krb5-devel, libidn-devel, libselinux-devel, libsepol-devel, openssl-devel, zlib-devel)。

Debian Linux 架設使用 SSH 存取 的 Git Server - Tsung's Blog

在 CentOS 5.5 上使用 yum 安装 Git - SoniTech

Downloads - git-core - Git - the stupid content tracker - Google Project Hosting
Simple Install of Git on Leopard

5 則留言 :

  1. 印象中有 rpm 可以裝吧 O_Oa

    1. 小聲說:CentOS 的兄弟「RHEL」不見得有.. :P

  2. 9 個月後,Git 已經來到,這次一樣先裝上 curl-devel.x86_64 後即可正常編譯。

    # yum install curl-devel.x86_64
    # ./configure --prefix=/usr/local/git
    # make && make install

    1. 還需手動補 PATH。
      # ln -s /usr/local/git/bin/* /usr/local/bin/