Multiple HTTP Git Repos Setup

Use mod_macro:

<Macro Project $repos>
<Location /git/$repos>
   DAV on
   AuthType Basic
   AuthName "Git for $repos"
   AuthUserFile /../htdocs/git/$repos/passwd.git
   Require valid-user
</Location>
</Macro>

Then you just add a single line for each repository

Use Project repos1
Use Project repos2

This isn't automatic unfortunately, i.e. it doesn't pick up all repositories in a directory, but you can run a cron job to create the config for you:

echo "# Git repository definitions" > /path/to/httpd_projectdef.conf
for i in /path/to/git/*; do echo "Use Project `basename $i`" >> /path/to/httpd_projectdef.conf; done

The project macro can also do the trac http config too if you wish.


If at all possible, I would suggest using SSH for sharing your repositories - it will offer better security, and generally work better as HTTP is a "dumb" protocol in Git terms. This also means you can use the standard file system permissions for controlling access, and you can have hook scripts run etc. HTTP is the lowest common denominator protocol for Git, and I think you would be better off using something else.

If you are stuck using HTTP for some reason, then pgs' answer is the way to go.


If all your repositories can use the same AuthUserFile, then will do, but I don't think that's what you're asking. You'll probably have to generate multiple Location sections externally, say with some perl code, and get apache to re-read the config files.

Have you considered using gitosis or git-daemon?

For your bonus question, something like:

alias /git /path/to/repository/root

<Directory "/path/to/repository/root">
   ...
</Directory>