Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on Mac OsX, trying to host my own git server. I've got gitolite running perfectly.

However, I have a folder called "git" in my Sites directory, such that visiting points to that directory.

How can I get Gitweb's document root to point to my gitolite "repositories" folder in /Users/me/repositories/?

share|improve this question

You need to add a file (like this one) which:

  • will be called by gitweb (if that file exists and defines a export_auth_hook sub, gitweb.cgi calls it)
  • will specify where the git repos are
  • will call gitolite

That would include:

$ENV{GL_REPO_BASE_ABS} = "$ENV{HOME}/repositories";
$export_auth_hook = sub {
    my $repo = shift;
    my $user = $ENV{GL_USER};
    # gitweb passes us the full repo path; so we strip the beginning
    # and the end, to get the repo name as it is specified in gitolite conf
    return unless $repo =~ s/^\Q$projectroot\E\/?(.+)\.git$/$1/;

    # check for (at least) "R" permission
    my $ret = &access( $repo, $user, 'R', 'any' );
    my $res = $ret !~ /DENIED/;
    return ($ret !~ /DENIED/);

With access() being a function of gitolite/src/lib/Gitolite/Conf/

Your httpd.conf would then call the gitweb.cgi script like in this one.

share|improve this answer
I'm still having the mismatch between the listing at and the the "txt" version at I pasted this into a file /etc/ – jessh Aug 20 '12 at 14:46
@jessh what version of Git are you using? – VonC Aug 20 '12 at 18:51
the most recent version git version (Apple Git-26) – jessh Aug 20 '12 at 20:30
@jessh ok, just checkng if the gitweb was a recent one (and it isn't really, but I don't know if that matters). Does your project.list includes all repos, including gitolite-admin? – VonC Aug 20 '12 at 21:03
@jessh It should be generated automatically by the gitolite installation. Another thing, the script automatically called by gitweb (if it exists) is actually gitweb_config.perl (…), which in turns calls my custom – VonC Aug 21 '12 at 4:00

Since I was missing my project.list, I created it myself. Then I chmod -r 755'ed the whole repositories directory. Working now!

share|improve this answer
So you didn't need the gitweb_conf.perl addon? – VonC Aug 22 '12 at 18:13
I didn't. Bizarre right? – jessh Aug 23 '12 at 2:01
So, is it really working? Meaning, if you declare in gitolite a repo as not visible for a certain user, will that user actually see or not said repo through your gitweb? – VonC Aug 23 '12 at 6:08
It seems similar to… – VonC Aug 24 '12 at 12:21
@VonC: A mystery to me - similar thing here: The projects.list exists, is accessible, and so the gitweb page shows "no such projects" (but not the 404 msg). At the same time, clicking the <txt> link in the lower right displays a projects.list with the two repos I selected to be public. Now I'm hesitant to install additional perl scripts and an apache redirect rule if it turns out that that's not really required. – cfi Feb 11 '13 at 11:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.