[更新 9/16/2010]
昨晚仔细研究后,我意识到我的原始问题实际上在问两件不同的事情:
1)是否可以为gitosis创建的所有远程存储库设置post-update钩子(即不必手动执行mv hooks/post-update.sample hooks/post-update
来创建gitosis存储库后)这对于通过HTTP克隆存储库是必要的(愚蠢的HTTP客户端依赖于从post-update hook内部调用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
的调用都将正确配置post-update钩子。(在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]
--- 仍在寻找第二个问题的解决方案...求助! :) ---
现在,HTTP克隆对于我所有的存储库都有效,我想知道是否有一种方法可以使用gitosis管理HTTP访问控制。将daemon = no
和gitweb = no
设置为关闭存储库的git-daemon和gitweb访问,但由于Apache重写规则仍然存在,因此存储库仍然可以通过 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
的新版本,仍在维护中(并且具有更多功能)。 - supakeen