简体   繁体   English

使用gitosis管理对git存储库的http访问

[英]Manage http access to git repositories using gitosis

[Update 9/16/2010] [2010年9月16日更新]

After looking into this last night, I realized that my original question was really asking 2 separate things: 在调查了昨晚之后,我意识到我原来的问题实际上是要求两个不同的东西:

1) Is it possible to set the post-update hook for all remote repositories created by gitosis (ie not have to manually perform mv hooks/post-update.sample hooks/post-update for after creating a repository in gitosis) This is necessary for cloning via HTTP to work (dumb HTTP clients rely on the fact that git update-server-info is called from within the post-update hook). 1)是否可以为gitosis创建的所有远程存储库设置更新后挂钩(即不必在gitosis中创建存储库后手动执行mv hooks/post-update.sample hooks/post-update )这是必要的通过HTTP克隆工作(哑客户端依赖于从更新后的钩子中调用git update-server-info的事实)。

2) Once the repository is accessible via HTTP, is it possible to turn access on and off using an option in gitosis.conf (something similar to daemon = no or gitweb = yes ) 2)一旦通过HTTP访问存储库,是否可以使用gitosis.conf中的选项打开和关闭访问(类似于daemon = nogitweb = yes

--- Solution to question 1 --- ---问题1的解决方案---

It turns out that Git uses templates to create new repositories with the git init command. 事实证明,Git使用模板使用git init命令创建新的存储库。 By performing mv hooks/post-update.sample hooks/post-update within the template directory, all future calls to git init on my server will have the post-update hook configured correctly. 通过在模板目录中执行mv hooks/post-update.sample hooks/post-update ,以后对我服务器上git init所有调用都将正确配置更新后挂钩。 (On OSX the template directory is /opt/local/share/git-core/templates/ for those that care) (在OSX上,模板目录是/opt/local/share/git-core/templates/对于那些关心的人)

The other requirement for this to work is turning on Apache rewrite rules so that the HTTP clone URL for the repository looks like http//git.example.com/repo.git 此工作的另一个要求是启用Apache重写规则,以便存储库的HTTP克隆URL看起来像http//git.example.com/repo.git

My rewrite rules in /etc/apache2/extra/httpd-vhosts.conf look like this: 我在/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]

--- Still looking for a solution to question 2...HELP! ---仍在寻找问题2的解决方案......帮助! :) --- :) ---

Now that HTTP cloning works for all my repositories, I'm wondering if there is a way to manage HTTP access control using gitosis. 既然HTTP克隆适用于我的所有存储库,我想知道是否有办法使用gitosis管理HTTP访问控制。 Setting daemon = no and gitweb = no turns off git-daemon and gitweb access for the repository, but since the Apache rewrite rules are still on, the repo is still clone-able at http://git.example.com/repo.git . 设置daemon = nogitweb = no会关闭存储库的git-daemon和gitweb访问权限,但由于Apache重写规则仍然存在, 因此repo仍然可以http://git.example.com/repo.git 克隆 http://git.example.com/repo.git Any ideas on how to use gitosis to manage this? 关于如何使用gitosis来管理这个的任何想法?

[The question I originally posted] [我最初发布的问题]

Is it possible to manage http access to git repositories using gitosis? 是否可以使用gitosis管理对git存储库的http访问? For example, in gitosis.conf I can manage access for gitweb and git-demon using: 例如,在gitosis.conf中,我可以使用以下命令管理gitweb和git-demon的访问:

# Allow gitweb to show this repository.
gitweb = yes

# Allow git-daemon to publish this repository.
daemon = no

I'm currently able to clone my repository by issuing the following command: 我现在可以通过发出以下命令来克隆我的存储库:

$ git clone git://git.example.com/repo.git

However, when I issue the following command: 但是,当我发出以下命令时:

$ git clone http://git.example.com/repo.git

I get the following error message: 我收到以下错误消息:

fatal: http://git.example.com/repo.git/info/refs not found: did you run git update-server-info on the server?

However, if I log into my server and run the following from within repo.git: 但是,如果我登录到我的服务器并从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

then cloning via http works fine. 然后克隆通过http工作正常。

Is there any way to manage http access to the repository from within gitosis? 有没有办法从gitosis中管理对存储库的http访问?

Was gitweb already setup and working? gitweb已经安装并正常工作了吗? Check this blog for instructions how to setup gitosis with gitweb. 查看此博客 ,了解如何使用gitweb设置gitosis。

BTW, Gitolite primary feature is that you can have very fine permissions. 顺便说一句,Gitolite的主要特点是你可以拥有非常好的权限。 ie. 即。 control permission per branch. 每个分支的控制权限。


UPDATE: I think gitosis integration w/ gitweb is basically whether it shows up on the project list. 更新:我认为gitosis整合w / gitweb基本上是否出现在项目列表中。 It doesn't control the permission to gitweb; 它不控制gitweb的权限; that is done via web server (apache). 这是通过Web服务器(apache)完成的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM