4.7 Git on the Server - GitWeb

GitWeb

Now that you have basic read/write and read-only access to your project, you may want to set up a simple web-based visualizer.
Git comes with a CGI script called GitWeb that is sometimes used for this.

Figure 49. The GitWeb web-based user interface.

If you want to check out what GitWeb would look like for your project, Git comes with a command to fire up a temporary instance if you have a lightweight server on your system like lighttpd or webrick.
On Linux machines, lighttpd is often installed, so you may be able to get it to run by typing git instaweb in your project directory.
If you’re running a Mac, Leopard comes preinstalled with Ruby, so webrick may be your best bet.
To start instaweb with a non-lighttpd handler, you can run it with the --httpd option.

That starts up an HTTPD server on port 1234 and then automatically starts a web browser that opens on that page.
It’s pretty easy on your part.
When you’re done and want to shut down the server, you can run the same command with the --stop option:

$ git instaweb --httpd=webrick --stop

If you want to run the web interface on a server all the time for your team or for an open source project you’re hosting, you’ll need to set up the CGI script to be served by your normal web server.
Some Linux distributions have a gitweb package that you may be able to install via apt or yum, so you may want to try that first.
We’ll walk though installing GitWeb manually very quickly.
First, you need to get the Git source code, which GitWeb comes with, and generate the custom CGI script:

Notice that you have to tell the command where to find your Git repositories with the GITWEB_PROJECTROOT variable.
Now, you need to make Apache use CGI for that script, for which you can add a VirtualHost:

Again, GitWeb can be served with any CGI or Perl capable web server; if you prefer to use something else, it shouldn’t be difficult to set up.
At this point, you should be able to visit http://gitserver/ to view your repositories online.