履歴: プログラミング/gitosis による git サーバーの管理
各行は、その日時に書かれた内容です。追加・削除は、1 つ前の版との行数の差です (全 26 版)。「差分」は比較する版、「基準」は比べる相手の版を選びます
| 日時 | タイトル | 文字数 | 追加 | 削除 | 内容 | 差分 | 基準 |
|---|---|---|---|---|---|---|---|
| 2025/7/18 7:54:41 | プログラミング/gitosis による git サーバーの管理 最新版 | 7,966 | +1 | -1 | 表示 | 差分 | — |
| 2025/7/18 7:54:41 | プログラミング/gitosis による git サーバーの管理 | 7,972 | +1 | -11 | 表示 | 差分 | 選択 |
| 2025/7/17 21:54:39 | プログラミング/gitosis による git サーバーの管理 | 8,260 | +11 | -1 | 表示 | 差分 | 選択 |
| 2025/7/16 11:44:31 | プログラミング/gitosis による git サーバーの管理 | 7,998 | +1 | -11 | 表示 | 差分 | 選択 |
| 2025/7/16 11:44:31 | プログラミング/gitosis による git サーバーの管理 | 8,207 | +11 | -1 | 表示 | 差分 | 選択 |
| 2025/1/25 2:12:02 | プログラミング/gitosis による git サーバーの管理 | 7,972 | +1 | -14 | 表示 | 差分 | 選択 |
| 2025/1/1 7:31:36 | プログラミング/gitosis による git サーバーの管理 | 8,823 | +2 | -1 | 表示 | 差分 | 選択 |
| 2024/12/10 17:05:27 | プログラミング/gitosis による git サーバーの管理 | 8,702 | +2 | -1 | 表示 | 差分 | 選択 |
| 2024/12/3 7:04:46 | プログラミング/gitosis による git サーバーの管理 | 8,578 | +2 | -1 | 表示 | 差分 | 選択 |
| 2024/12/2 3:43:24 | プログラミング/gitosis による git サーバーの管理 | 8,451 | +2 | -1 | 表示 | 差分 | 選択 |
| 2024/11/20 13:59:17 | プログラミング/gitosis による git サーバーの管理 | 8,327 | +2 | -1 | 表示 | 差分 | 選択 |
| 2024/10/29 23:01:00 | プログラミング/gitosis による git サーバーの管理 | 8,152 | +9 | -1 | 表示 | 差分 | 選択 |
| 2024/9/13 17:43:32 | プログラミング/gitosis による git サーバーの管理 | 7,972 | +1 | -11 | 表示 | 差分 | 選択 |
| 2024/9/10 23:48:53 | プログラミング/gitosis による git サーバーの管理 | 8,272 | +11 | -0 | 表示 | 差分 | 選択 |
| 2015/2/14 16:32:01 | プログラミング/gitosis による git サーバーの管理 | 7,895 | +1 | -1 | 表示 | 差分 | 選択 |
| 2015/2/14 7:32:01 | プログラミング/gitosis による git サーバーの管理 | 7,894 | +32 | -0 | 表示 | 差分 | 選択 |
| 2014/5/12 0:01:30 | プログラミング/gitosis による git サーバーの管理 | 7,078 | +16 | -0 | 表示 | 表示中 | 選択 |
| 2013/8/21 2:10:17 | プログラミング/gitosis による git サーバーの管理 | 6,683 | +7 | -0 | 表示 | 差分 | 選択 |
| 2011/3/24 9:03:36 | プログラミング/gitosis による git サーバーの管理 | 6,477 | +4 | -0 | 表示 | 差分 | 選択 |
| 2010/1/11 14:16:19 | プログラミング/gitosis による git サーバーの管理 | 6,392 | +1 | -1 | 表示 | 差分 | 選択 |
| 2010/1/11 14:16:19 | プログラミング/gitosis による git サーバーの管理 | 6,393 | +1 | -1 | 表示 | 差分 | 選択 |
| 2010/1/11 14:16:19 | プログラミング/gitosis による git サーバーの管理 | 6,393 | +60 | -22 | 表示 | 差分 | 選択 |
| 2010/1/11 12:38:45 | プログラミング/gitosis による git サーバーの管理 | 5,389 | +97 | -27 | 表示 | 差分 | 選択 |
| 2009/6/10 17:53:47 | プログラミング/gitosis による git サーバーの管理 | 3,657 | +6 | -0 | 表示 | 差分 | 基準 |
| 2009/6/10 17:53:47 | プログラミング/gitosis による git サーバーの管理 | 3,601 | +8 | -1 | 表示 | 差分 | 選択 |
| 2009/6/10 17:42:19 | プログラミング/gitosis による git サーバーの管理 | 3,517 | — | — | 表示 | — | 選択 |
基準: プログラミング/gitosis による git サーバーの管理 (2009/6/10 17:53:47) → 比較: プログラミング/gitosis による git サーバーの管理 (2014/5/12 0:01:30)
@@ -4,36 +4,79 @@
* gitosis について [#kf89cbe7]
-gitosis の説明は
+gitosis は、(複数の)git リポジトリの管理を容易に行うためのソフトウェア。~
+詳しい説明は、http://openbooth.org/archives/60.html あたりを参照のこと。
-- http://openbooth.org/archives/60.html
+gitosis により管理されるサーバーには
+ git clone gitosis-account@some.your.server.com:some-project
-あたりを。
+のような形でアクセスすることになる。
-* Debian における gitosis リポジトリの作成 [#l4afdd75]
+:some.your.server.com| gitosis をインストールしたサーバーのアドレス
+:gitosis-account| some.your.server.com に(通常は)1つだけ作成された gitosis 用のアカウント名~
+すべてのユーザーはこのアカウントを通じてリポジトリにアクセスする
+:some-project| git リポジトリの名前~
+1つの gitosis-account で複数の git リポジトリを管理することができる
+リポジトリへのアクセス制御は公開鍵(rsa)ベースで、
+ユーザーごと、そして、リポジトリごとに、
+読み取り専用、または、読み書き可能、を指定できる。
+
+git リポジトリの以下のような管理は、shell ログインすることなく git を使ってリモートから行える。
+- 新しいリポジトリの作成
+- ユーザーアカウントの追加・削除
+- リポジトリごと、ユーザーごとのアクセス制御
+
+** gitolite について [#yf81147c]
+
+(2013-08-21 追記) 最近は gitosis よりも gitolite の方が人気があるのかもしれません。
+
+https://www.google.co.jp/search?q=gitosis+gitolite ~
+http://www.atmarkit.co.jp/ait/articles/1110/03/news112.html ~
+
+** gitlab について [#r4297b50]
+
+(2014-05-12 追記) gitolite の GUI として人気のあった gitlab が、最近は gitolite
+に頼らずスタンドアローンで git の管理ができるようになっているのだそうです。
+
+Ruby on Rails 製なので、低負荷なら Webrick で簡単に動かせますし、
+それなりの環境を整えれば高負荷まで対応可能。自分だけの GitHub
+(のようなもの)を構築できるということで、
+Web + Redis (+ MySQL) サーバを建てられる人限定ですが、お勧めです。
+(低負荷であればデータベースは SQLite でも?)
+
+https://www.gitlab.com/
+
+バージョンアップの頻度が高いため、
+インストールの仕方などはなるべく新しい情報を参照すると間違いがないと思います。
+
+* Debian での gitosis のインストール [#l4afdd75]
+
- http://openbooth.org/archives/65.html
と同様にやれば良いんだけれど、
-はまるのは、git というユーザーではうまく行かない事。
+はまるのは、git というユーザーを使おうとするとうまく行かない事。
gitosis というユーザーが自動的に作られるので、それを使う。
+手順としては、
++ aptitude で gitosis をインストール (1行目:aptitude install)
++ 1人目の管理者(自分)の公開鍵を用いて gitosis を初期化 (10行目:gitosis-init)
++ 自分のアカウントからアクセスできることを確認する (17行目:ssh)
+
LANG:console
$ sudo aptitude install gitosis
以下の新規パッケージがインストールされます:
gitosis python-pkg-resources{a} python-setuptools{a}
更新: 0 個、新規インストール: 3 個、削除: 0 個、保留: 0 個。
284kB のアーカイブを取得する必要があります。展開後に 1217kB のディスク領域が新たに消費されます。
- $ cp ~/.ssh/id_rsa.pub ~gitosis/osamu_id_rsa.pub
$ sudo su gitosis
gitosis$ cd
gitosis$ pwd
/srv/gitosis
- gitosis$ gitosis-init < osamu_id_rsa.pub
+ gitosis$ gitosis-init < ~osamu/.ssh/id_rsa.pub
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/
- gitosis$ rm osamu_id_rsa.pub
gitosis$ ls -a
.ssh gitosis repositories
gitosis$ exit
@@ -42,27 +85,37 @@
PTY allocation request failed on channel 0
ERROR:gitosis.serve.main:Need SSH_ORIGINAL_COMMAND in environment.
Connection to localhost closed.
- $ git clone gitosis@localhost:gitosis-admin.git
- Initialized empty Git repository in /home/osamu/gitosis-admin/.git/
- remote: Counting objects: 5, done.
- remote: Compressing objects: 100% (4/4), done.
- remote: Total 5 (delta 0), reused 5 (delta 0)
- Receiving objects: 100% (5/5), done.
- $ cd gitosis-admin/
+最後の一行、エラーになっているように見えるが、**ログインが成功した後**、
+何も Git のコマンドを指定していないので、接続が拒否された、という意味。
+
* 管理作業 [#u5d1b577]
- http://openbooth.org/archives/82.html
-を参考に、osamu@another-server を管理者として登録してみる。
+を参考に、osamu@another-server をもう1人の管理者として登録してみる。
+gitosis のリポジトリ管理情報は、それ自体1つの git リポジトリで管理されているので、
+その編集手順は次のようになる。
+
++ 管理情報リポジトリである gitosis-admin をローカルにコピー : git clone
++ 管理情報をローカルで編集 : gitosis.conf をエディタで編集したり、公開鍵を keydir にコピーしたり
++ 編集結果をローカルリポジトリに登録 : git add / git commit
++ ローカルリポジトリをサーバーに送信 : git push
+
LANG:console
- $ pwd
- ~/gitosis-admin/
+ $ git clone gitosis@localhost:gitosis-admin.git
+ Initialized empty Git repository in /home/osamu/gitosis-admin/.git/
+ remote: Counting objects: 5, done.
+ remote: Compressing objects: 100% (4/4), done.
+ remote: Total 5 (delta 0), reused 5 (delta 0)
+ Receiving objects: 100% (5/5), done.
$ ls
- gitosis.conf
-
- keydir:
+ gitosis-admin
+ $ cd gitosis-admin/
+ $ ls
+ gitosis.conf keydir
+ $ ls keydir
osamu@debian-server.pub
$ cat gitosis.conf
[gitosis]
@@ -77,6 +130,8 @@
writable = gitosis-admin
members = osamu@debian-server, osamu@another-server
$ scp osamu@another-server:.ssh/id_rsa.pub keydir/osamu@another-server.pub
+ $ ls keydir
+ osamu@another-server osamu@debian-server
$ git add keydir/osamu@another-server.pub
$ git commit -a
Created commit d7e6afb: osamu@another-server.pub was added as admin
@@ -93,7 +148,8 @@
To gitosis@localhost:gitosis-admin.git
31412ce..d7e6afb master -> master
-これで追加されているはず。
+これで、新しいユーザーが追加され、
+登録した公開鍵を使って gitosis アカウントにログイン可能になっている。
LANG:console
$ ssh osamu@another-server
@@ -108,36 +164,54 @@
うまく行っている。
-* gitosis.conf の設定方法 [#u6460df3]
+** 管理情報の構成 [#xf612861]
+gitosis の管理情報は以下のようなファイル構成になっている。
+
+ gitosis-admin/
+ gitosis.conf
+ keydir/
+ osamu@another-server.pub
+ osamu@debian-server.pub
+
+:gitosis.conf| 管理情報フォルダのルートにある~
+リポジトリごと、ユーザーアカウントごとのアクセス制御情報が書かれている
+:keydir/*| ユーザーアカウントごとの公開鍵がユーザー名と同名のファイルとして保存される
+
+** gitosis.conf の設定方法 [#u6460df3]
+
使い方は /usr/share/doc/gitosis/example/* を見る。
基本は、
[group グループ名]
- members = member1 member2 member3 ...
+ members = member1 member2 member3 @other-group ...
writable = リポジトリ1 リポジトリ2 リポジトリ3 ...
readonly = リポジトリ1 リポジトリ2 リポジトリ3 ...
という設定。
+member? は keydir/* に保存した公開鍵ファイルの名前で指定する。~
+他のグループ名を @ 付きで指定することもできる。
+
+gitosis-admin リポジトリ自体もこの形式のアクセス制御が可能なので、
+上記のように複数の管理者アカウントを作成・管理することができる。
+
あとは、必要に応じてリポジトリごとの設定。
- [repo foo]
+ [repo リポジトリ1]
## Allow gitweb to show this repository.
- gitweb = yes
+ #gitweb = yes
## Oneline description of the project, mostly for gitweb.
- description = blah blah
+ #description = blah blah
## Owner of this repository. Used in gitweb list of projects.
- owner = John Doe
+ #owner = John Doe
## Allow git-daemon to publish this repository.
- daemon = yes
+ #daemon = yes
-gitosis でリポジトリへの書き込み権限を作ってから git push することになる。
-
設定は、書き換えたら
LANG:console
git commit -a -m "message"
@@ -145,6 +219,67 @@
を忘れずに行う。
+** ユーザーの追加・削除 [#s04b5858]
+
+上記の通り、keydir に追加したいユーザーの公開鍵をユーザー名と同じファイル名で保存し、
+gitosis.conf の適当なグループにそのユーザー名を追加する。
+
+削除するには、gitosis.conf からユーザー名を削除する。
+
+** 新たなリポジトリを作成する [#w677ce31]
+
+新しいリポジトリを作成するには、まず上記方法でリポジトリへの書き込み権限を作ってから
+git push することになる。
+
+以下では、新たに my_project というリポジトリに対して、
+読み書き可能なユーザーグループ myteam を作成し、
+member1, member2, member3 の3人をメンバーとして登録する。
+
+その後、ローカルの my_project リポジトリをサーバーに push することで、
+サーバー上に my_project というリポジトリを作成する。
+
+ LANG:console
+ $ git clone gitosis@my.debian-server.com:gitosis-admin.git
+ ...
+
+ $ cd gitosis-admin/
+ $ jed gitosis.conf
+ ...
+
+ [group myteam]
+ members = member1 member2 member3
+ writable = my_project
+ ...
+
+ $ git commit -a -m "my_project created"
+ $ git push
+ $ mkdir my_project
+ $ cd my_project
+ $ git init
+ $ git remote add origin gitosis@git.server.com:my_project.git
+ $ # do some work, git add and commit files
+ $ git push origin master:refs/heads/master
+
+** リポジトリを削除する [#d82f16b5]
+
+リモートから行うことはできない。
+
+すべてのユーザーから読み書きの権限を剥奪することでリポジトリが存在しないのと
+同じ状況にすることはできるが、実際にデータ自体を削除するためには Shell ログインの後、
+
+~gitosis/repositories にて、sudo rm -rf project-name などとする必要がある。
+
+ちなみに、~gitosis は Debian のデフォルトでは /srv/gitosis になっている。
+
+* フックの使い方 [#w8d68051]
+
+git リポジトリにフックを仕込むことで、リポジトリの更新時にメールを送信するなどが
+可能となる・・・のではないかとの記述を目にした。後で調べてみよう。
+
+(2011/03/24 追記)~
+http://labs.gree.jp/blog/2011/03/2885/ ~
+こちらのサイトに詳しく使い方が紹介されていました。
+
* コメント [#z8ca5a65]
自由にコメントを付けて下さい。