【发布时间】:2010-09-15 22:21:26
【问题描述】:
[2010 年 9 月 16 日更新]
昨晚看了这个之后,我意识到我最初的问题实际上是在问两个不同的问题:
1) 是否可以为 gitosis 创建的所有远程存储库设置更新后挂钩(即在 gitosis 中创建存储库后不必手动执行mv hooks/post-update.sample hooks/post-update)这是通过 HTTP 克隆工作所必需的(愚蠢的 HTTP 客户端依赖于 git update-server-info 是从更新后挂钩中调用的事实。
2) 一旦可以通过 HTTP 访问存储库,是否可以使用 gitosis.conf 中的选项打开和关闭访问(类似于 daemon = no 或 gitweb = yes)
---问题1的解答---
事实证明,Git 使用模板通过 git init 命令创建新的存储库。通过在模板目录中执行mv hooks/post-update.sample hooks/post-update,以后在我的服务器上对git init 的所有调用都将正确配置更新后挂钩。 (在 OSX 上,模板目录是 /opt/local/share/git-core/templates/ 供那些关心的人使用)
要使其正常工作的另一个要求是打开 Apache 重写规则,以便存储库的 HTTP 克隆 URL 看起来像 http//git.example.com/repo.git
我在/etc/apache2/extra/httpd-vhosts.conf 中的重写规则如下所示:
# turning on mod rewrite
RewriteEngine on
# make the front page an internal rewrite to the gitweb script
RewriteRule ^/$ /cgi-bin/gitweb.cgi [L,PT]
# make access for "dumb clients" work
RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
--- 仍在寻找问题 2 的解决方案...帮助! :) ---
现在 HTTP 克隆适用于我的所有存储库,我想知道是否有一种方法可以使用 gitosis 来管理 HTTP 访问控制。设置 daemon = no 和 gitweb = no 会关闭存储库的 git-daemon 和 gitweb 访问,但由于 Apache 重写规则仍然启用,repo 仍然可以克隆 在http://git.example.com/repo.git。关于如何使用 gitosis 来管理此问题的任何想法?
[我最初发布的问题]
是否可以使用 gitosis 管理对 git 存储库的 http 访问?例如,在 gitosis.conf 中,我可以使用以下命令管理 gitweb 和 git-demon 的访问:
# Allow gitweb to show this repository.
gitweb = yes
# Allow git-daemon to publish this repository.
daemon = no
我目前可以通过发出以下命令来克隆我的存储库:
$ git clone git://git.example.com/repo.git
但是,当我发出以下命令时:
$ git clone http://git.example.com/repo.git
我收到以下错误消息:
fatal: http://git.example.com/repo.git/info/refs not found: did you run git update-server-info on the server?
但是,如果我登录到我的服务器并从 repo.git 中运行以下命令:
# From http://progit.org/book/ch4-5.html
$ cd project.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod a+x hooks/post-update
$ git update-server-info
然后通过 http 克隆可以正常工作。
有没有办法在 gitosis 中管理对存储库的 http 访问?
【问题讨论】:
-
不是对您问题的回答,但我听说
gitolite是新的、仍在维护(并具有更多功能)版本的 gitosis。
标签: git gitosis githooks gitweb post-update