Git: configure Git over HTTP

The most basic Git configuration allows anonymous read access to the Git repository using the git-http-backend script provided with Git versions 1.6.6 and greater.

The only thing to do is modify the Apache configuration to use the git-http-backend script. Ensure mod_cgi, mod_alias, and mod_env are enabled, set GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and create a ScriptAlias to the CGI. The GIT_PROJECT_ROOT should point to the root folder where git repositories would be hosted.

DocumentRoot /var/www/git
<Directory "/var/www/git">
Allow from All
Options +ExecCGI
AllowOverride All
SetEnv GIT_PROJECT_ROOT /var/www/git
ScriptAlias /git /usr/lib/git-core/git-http-backend

At this point an anonymous user should be able to clone the project repository by issuing the following command:

git clone

Note: Users are not yet able to push changes back to the repository.

Note: Adding the SuExec directive in the base configuration will cause the git-http-backend script to cease functioning correctly.