Git サーバー gitosis のインストールと設定
github を利用しようかなーと思ったんですけど、複数人で秘密リポジトリが使えるプランは、零細企業には高いっすわー。ということで、せっかく遠隔ペアプログラミング用にさくらのVPSを借りているので、そこに Git サーバーを立てることにしました。
インストール:
$ sudo aptitude install gitosis
あ、Ubuntu なので。他のディストリビューションは知らん。
初期化します。同時に設定を嬲れるユーザーの公開鍵を登録します:
$ sudo -H -u gitosis gitosis-init < ~/.ssh/id_rsa.pub
設定は、gitosis サーバーから gitosis-admin というリポジトリを clone して、編集して、commit して、push することで行います。
以下では sample というリポジトリを、私と test@example.com というユーザーが読み書きできるように設定してみます。
設定ファイルを格納している gitosis-admin リポジトリを取得:
$ git clone gitosis@localhost:gitosis-admin.git
新規リポジトリ用の設定を追加:
$ cd gitosis-admin $ vi gitosis.conf [group sample] writable = sample members = babie@example.com test@example.com
test ユーザーの公開鍵を配置:
$ cd keydir $ ls babie@example.com.pub $ sudo cp ~test/.ssh/id_rsa.pub . $ ls -l -rw-rw-r-- 1 babie babie 404 2011-04-21 10:38 babie@example.com.pub -rw-r--r-- 1 root root 399 2011-04-21 10:43 id_rsa.pub $ sudo chown babie:babie id_rsa.pub $ ls -l -rw-rw-r-- 1 babie babie 404 2011-04-21 10:38 babie@example.com.pub -rw-r--r-- 1 babie babie 399 2011-04-21 10:43 id_rsa.pub $ mv id_rsa.pub test@example.com.pub $ ls babie@example.com.pub test@example.com.pub
設定変更を反映:
$ cd .. $ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: gitosis.conf # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # keydir/test@example.com.pub no changes added to commit (use "git add" and/or "git commit -a") $ git add . $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: gitosis.conf # new file: keydir/test@example.com.pub # $ git commit -m "add sample repos and test user" $ git push origin master
んで、リポジトリのプレースホルダができたので、リポジトリを push すれば共有できます:
$ cd ~/dev/sample $ git init . $ git add . $ git commit -m 'initial commit' $ git remote add origin gitosis@localhost:sample.git $ git push origin master
以上。
リポジトリをブラウザで閲覧できる gitweb のインストールと設定はまた今度。