Mac上にgitの公開リポジトリを作る

git 1.6.3.3 on Mac OS X 10.5

以下の方法でとりあえず動く。ただし安全かどうかは保障できない。

git-coreのインストール

$ sudo port install git-core +gitweb # 一応gitwebも

リポジトリの置き場所を作る

ここでは/opt/local/var/git/repos以下にリポジトリを作ると仮定する。

$ sudo mkdir /opt/local/var/git/repos
$ cd /opt/local/var/git/repos

daemonを起動

$ sudo /opt/local/libexec/git-core/git-daemon --export-all --enable=receive-pack --base-path=/opt/local/var/git/repos

–base-pathでリポジトリの置き場所を指定する。–export-allと–enable=receive-packはまだよくわかってない。

リポジトリを作る

新規に空のリポジトリを作る場合は次を実行。

$ cd /opt/local/var/git/repos
$ sudo mkdir testrepos.git
$ cd testrepos.git
$ sudo git init --bare
$ sudo touch git-daemon-export-ok

どっかからクローンしてくる場合(例えば既存のローカルリポジトリ/path/to/cloned/reposを公開したい場合)には次を実行。こっちのがsudoをあまりしなくて済むので楽かも。

$ cd /opt/local/var/git/repos
$ sudo git clone --bare /path/to/cloned/repos ./testrepos.git
$ sudo touch git-daemon-export-ok
$ sudo touch testrepos.git/git-daemon-export-ok

どちらにせよ–bareが大事。

cloneしてみる

$ cd ~/tmp
$ git clone git://hostname/testrepos.git

ToDo

  • git-daemon-export-okってなに。
  • –export-allってなに。
  • –enable=receive-packってなに。
  • 今のとこroot権限でリポジトリが作成されてるんだけど、そこらへんどうなんだろう。
  • ネットワーク越しのローカルレポジトリから公開リポジトリを作るにはどうすればいいんだろう。
  • launchctlに登録したい。

参考資料


Comments

  1. わんこ

    2010/10/30 Saturday at Oct 30, 2010 11:06

    ・git-daemon-export-okってなに。 →そのリポジトリをgit-deamonで公開して良いという印

    ・–export-allってなに。 →git-daemon-export-okファイルが無くてもすべてのリポジトリをgit-daemonで公開するためのオプション

    ・–enable=receive-packってなに →git-daemmonでpushされることを許すオプション。これがついていないと、公開はするのでクライアントからcloneなどができるが、クライアントからの書き込みが禁止されるのでpushができない。

    って感じだったと思います。


  2. ikm

    2010/11/2 Tuesday at Nov 02, 2010 01:48

    @わんこさん 詳しい説明をありがとうございます! あとになって気づいたんですが、ここらへんってgit-daemonのmanに載ってたんですね。 あまりmanを読む癖がなかったので…


Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">