Git introduced a new transfer protocol in version 1.6.6 known as "smart HTTP", and every bit of documentation I've seen and read so far showed how to get it up and running in Apache. If you are interested in doing that, I highly recommend this informative post from the author of Pro Git. Even if you aren't looking to get it running on Apache, it does much more justice (and includes pictures!) describing what the smart HTTP transport actually is.

I run lighttpd on my server, so directions dealing with Apache weren't of much use to me, unfortunately. The aforementioned post states "it has to be Apache, currently - other CGI servers don’t work, last I checked." I had a hard time believing that so I set out to make it work on lighttpd. The short answer- it completely works after getting the config right.

Basic configuration

I'm currently running version 1.7.0.2 of git on my server, but you will need to be using at least version 1.6.6. If running locate git-http-backend turns up nothing, you are out of luck.

The config snippet below is entirely based off what I am using. I've changed it here only to make it much simpler and easier to understand; this domain would do nothing but serve the git smart HTTP stuff.

$HTTP["host"] == "git.mydomain.com" {
  alias.url               += ( "/git" => "/usr/lib/git-core/git-http-backend")
  # prevent a request to "/git" from causing a 500 error (no PATH_INFO)
  url.rewrite-once         = ( "^/git$" => "/git/" )
  $HTTP["url"] =~ "^/git" {
    # turn on CGI unconditionally for this URL
    cgi.assign = ( "" => "" )
    setenv.add-environment = (
      "GIT_PROJECT_ROOT" => "/srv/git",
      "GIT_HTTP_EXPORT_ALL" => ""
    )
  }
}

Results and doing it yourself

Obviously you will need to make a few adjustments to your environment to get the config working. Ensure you adjust the above snippet for your correct path to git-http-backend as well as setting the correct GIT_PROJECT_ROOT. You will also need to have at least the mod_cgi and mod_setenv lighttpd modules enabled.

Once a config like the one above is in place, the smart HTTP serving should be in place at a location like http://my.domain.com/git/myrepository.git. An easy way to check is to do a git clone on the HTTP URL of one of your repositories; if you see messages like remote: Counting objects: 722, done. then you have successfully set it up.

The repositories on code.toofishes.net are now serving up smart HTTP if you were cloning from or referencing my repositories via the HTTP URLs, so let me know if you see any problems.