gitをインストールしてみる

最近では、subversionよりもgitの方がバージョン管理に使われ初めてており、GitHubにてソースを公開されている場合があるので、インストールしてみました。

gitとは、Linuxカーネルの開発などで使用されている分散バージョン管理システムで、詳細は他に詳しく書かれているサイトがあるので、そちらを見てください。

と前置きはそれぐらいにして、gitのインストールを行います。MacPortsにgit系のパッケージが用意されており、portコマンドを使ってのインストールなので非常に簡単です。

$ sudo port install git-core
--->  Fetching pkgconfig
--->  Attempting to fetch pkg-config-0.23.tar.gz from http://distfiles.macports.org/pkgconfig
--->  Verifying checksum(s) for pkgconfig
--->  Extracting pkgconfig
--->  Configuring pkgconfig
--->  Building pkgconfig
--->  Staging pkgconfig into destroot
--->  Packaging tgz archive for pkgconfig 0.23_1
--->  Installing pkgconfig @0.23_1
--->  Activating pkgconfig @0.23_1
--->  Cleaning pkgconfig
--->  Fetching curl
--->  Attempting to fetch curl-7.19.2.tar.bz2 from http://distfiles.macports.org/curl
--->  Verifying checksum(s) for curl
--->  Extracting curl
--->  Configuring curl
--->  Building curl
--->  Staging curl into destroot
--->  Packaging tgz archive for curl 7.19.2_0
--->  Installing curl @7.19.2_0
--->  Activating curl @7.19.2_0
--->  Cleaning curl
--->  Fetching p5-error
--->  Attempting to fetch Error-0.17015.tar.gz from ftp://ftp.cpan.org/pub/CPAN/modules/by-module/Error
--->  Verifying checksum(s) for p5-error
--->  Extracting p5-error
--->  Configuring p5-error
--->  Building p5-error
--->  Staging p5-error into destroot
--->  Packaging tgz archive for p5-error 0.17015_0
--->  Installing p5-error @0.17015_0
--->  Activating p5-error @0.17015_0
--->  Cleaning p5-error
--->  Fetching popt
--->  Attempting to fetch popt-1.14.tar.gz from http://distfiles.macports.org/popt
--->  Verifying checksum(s) for popt
--->  Extracting popt
--->  Configuring popt
--->  Building popt
--->  Staging popt into destroot
--->  Packaging tgz archive for popt 1.14_0
--->  Installing popt @1.14_0
--->  Activating popt @1.14_0
--->  Cleaning popt
--->  Fetching rsync
--->  Attempting to fetch rsync-3.0.4.tar.gz from http://distfiles.macports.org/rsync
--->  Verifying checksum(s) for rsync
--->  Extracting rsync
--->  Applying patches to rsync
--->  Configuring rsync
--->  Building rsync
--->  Staging rsync into destroot
--->  Packaging tgz archive for rsync 3.0.4_0
--->  Installing rsync @3.0.4_0
--->  Activating rsync @3.0.4_0
--->  Cleaning rsync
--->  Fetching git-core
--->  Attempting to fetch git-1.6.0.5.tar.bz2 from http://distfiles.macports.org/git-core
--->  Attempting to fetch git-manpages-1.6.0.5.tar.bz2 from http://distfiles.macports.org/git-core
--->  Attempting to fetch git-htmldocs-1.6.0.5.tar.bz2 from http://distfiles.macports.org/git-core
--->  Verifying checksum(s) for git-core
--->  Extracting git-core
--->  Applying patches to git-core
--->  Configuring git-core
--->  Building git-core
--->  Staging git-core into destroot
--->  Packaging tgz archive for git-core 1.6.0.5_0+doc
--->  Installing git-core @1.6.0.5_0+doc
--->  Activating git-core @1.6.0.5_0+doc
--->  Cleaning git-core

ここまでやっておきながら、インストールのオプションの存在に気付いたので、ちょっとやり直すことにしました。まずは、どんなオプションが存在するのか確認します。

$ port variants git-core
git-core has the variants:
        doc: Install HTML and plaintext documentation
        gitweb: Install gitweb.cgi
        svn: Bi-directional subversion repository support
        bash_completion: Bash completion support

ドキュメントとbash補完サポートぐらいがあればいいかなと思うので、オプションに入れてインストールし直します。

$ sudo port install git-core +doc +bash_completion
Password:
--->  Fetching bash-completion
--->  Attempting to fetch bash-completion-20060301.tar.bz2 from http://distfiles.macports.org/bash-completion
--->  Verifying checksum(s) for bash-completion
--->  Extracting bash-completion
--->  Configuring bash-completion
--->  Building bash-completion
--->  Staging bash-completion into destroot
--->  Packaging tgz archive for bash-completion 20060301_1
--->  Installing bash-completion @20060301_1
To use bash_completion, add the following lines at the end of your .bash_profile:

    if [ -f /opt/local/etc/bash_completion ]; then
        . /opt/local/etc/bash_completion
    fi

--->  Activating bash-completion @20060301_1
--->  Cleaning bash-completion
--->  Fetching git-core
--->  Verifying checksum(s) for git-core
--->  Extracting git-core
--->  Applying patches to git-core
--->  Configuring git-core
--->  Building git-core
--->  Staging git-core into destroot
--->  Packaging tgz archive for git-core 1.6.0.5_0+bash_completion+doc
--->  Installing git-core @1.6.0.5_0+bash_completion+doc
--->  Activating git-core @1.6.0.5_0+bash_completion+doc
Error: Target org.macports.activate returned: Image error: Another version of this port (git-core @1.6.0.5_0+doc) is already active.
Error: Status 1 encountered during processing.

むむむっ、エラーになっちゃいました。どうやらgit-coreが既に有効な状態になっているのが問題みたいなので、一旦無効にします。

$ sudo port deactivate git-core
--->  Deactivating git-core

もう一度、オプション付きでインストールしてみます。

$ sudo port install git-core +doc +bash_completion
--->  Activating git-core @1.6.0.5_0+bash_completion+doc
--->  Cleaning git-core

今度は、問題なくインストールが完了しました。最後にインストール時の指示に従い、bash補完を有効にするために ~/.bash_profile に以下の3行を追記します。

if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

おまけ

Ubuntuの場合だと、gitに関連したパッケージが以下のように存在します。

  • git - GNU Interactive Tools, a file browser/viewer and process viewer/killer
  • git-arch - fast, scalable, distributed revision control system (arch interoperability)
  • git-buildpackage - Suite to help with Debian packages in Git repositories
  • git-completion
  • git-core - fast, scalable, distributed revision control system
  • git-cvs - fast, scalable, distributed revision control system (cvs interoperability)
  • git-daemon-run - fast, scalable, distributed revision control system (git-daemon service)
  • git-doc - fast, scalable, distributed revision control system (documentation)
  • git-email - fast, scalable, distributed revision control system (email add-on)
  • git-gui - fast, scalable, distributed revision control system (GUI)
  • git-load-dirs - Import upstream archives into git
  • git-svn - fast, scalable, distributed revision control system (svn interoperability)
  • gitk - fast, scalable, distributed revision control system (revision tree visualizer)
  • gitpkg - helper scripts for maintaining packages with git
  • gitweb - fast, scalable, distributed revision control system (web interface)

最低限のパッケージだけインストールできればよいので、以下のコマンドでインストールします。

$ sudo aptitude install git-core git-doc git-completion