From Git SCM Wiki
Jump to: navigation, search


Install GitWeb CGI on Windows

Latest msysGit comes already with gitweb.cgi located in the ./share/gitweb folder. Since I hate installers I personally prefer to use PortableGit 7-Zip archive; if you prefer the installer you probably have to adapt the paths. So lets assume that you have downloaded the PortableGit 7-Zip archive and extracted with 7-Zip to C:\git-

GitWeb with Apache

First you need to configure Apache to serve the gitweb directory:

# Config to make the gitweb CGI available through Apache.
Alias /gitweb "c:/git-"
<Directory "c:/git-">
  AddHandler cgi-script .cgi
  <Files ~ "\.cgi$">
    Options +ExecCGI
  AllowOverride None
  Order allow,deny
  Allow from all
  DirectoryIndex gitweb.cgi

and while at Apache config lets also just add the html docs so we can view them from browser too:

# Config to make the Git html docu available through Apache.
Alias /gitdocs "c:/git-"
<Directory "c:/git-">
  Options Includes Indexes MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all

Instead of appending the above to Apache's httpd.conf you can also just create a separate file, f.e. C:\git-\httpd-git.conf and then only add one line to httpd.conf to include this config:

Include c:/git-

Dont forget to restart the Apache service to activate the changes.

The gitweb.cgi does not work with ActivePerl - you will get this in the Apache error.log:

gitweb.cgi: List form of pipe open not implemented at C:/git- line 2709.

fortunately mysysGit comes with its own Perl which does better - unfortunately msysGit Perl lacks of the module which is required for running CGIs; so either download and install it from CPAN, or if you have an ActivePerl installation somewhere handy just copy it over from there.

Apache evaluates the unix shebang in Perl scripts to determine the script interpreter which should be used; so you need to change the first line in the gitweb.cgi script to look like this:


gitweb.cgi needs to know where to find git.exe, therefore configure in line 71:

our $GIT = "C:/git-";

Now have done almost all preparations, just one thing is missing: the path to your repos. Since git.exe must evaluate this path it must be in msys syntax, f.e. if you have located your git repos at D:\git-repos then you have to use:

our $projectroot = "/d/git-repos";

That's it! You can now test to access the configured aliases with your browser ...

For further docu see also gitweb/README.


Use always forward slashes in the gitweb.cgi and also in the Apache config!

GitWeb with IIS

Git Web Access

For those who have interests in a Smart-HTTP Git server on IIS, the project provides an ASP.NET HttpHandler that let you run Smart HTTP Git on IIS. It is inspired by Grack, a Ruby Rack based application for Smart HTTP Git and, a python implementation of Smart HTTP Git.

The ASP.HET handler, GitHandler, is lightweight and can be used in any ASP.NET web applications and web sites. Another reusable piece is the WCF data service that exposes Git repository through WCF data services / OData protocol. The OData feed can be used to plot the commit graph on HTML5 canvas.

Personal tools