Install GitWeb CGI on Windows
Latest msysGit 22.214.171.124 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-126.96.36.199.
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-188.8.131.52/share/gitweb" <Directory "c:/git-184.108.40.206/share/gitweb"> AddHandler cgi-script .cgi <Files ~ "\.cgi$"> Options +ExecCGI </Files> AllowOverride None Order allow,deny Allow from all DirectoryIndex gitweb.cgi </Directory>
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-220.127.116.11/doc/git/html" <Directory "c:/git-18.104.22.168/doc/git/html"> Options Includes Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory>
Instead of appending the above to Apache's httpd.conf you can also just create a separate file, f.e. C:\git-22.214.171.124\httpd-git.conf and then only add one line to httpd.conf to include this config:
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-126.96.36.199/share/gitweb/gitweb.cgi line 2709.
fortunately mysysGit comes with its own Perl which does better - unfortunately msysGit 188.8.131.52 Perl lacks of the CGI.pm 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-184.108.40.206/bin/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 git_http_backend.py, 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.