GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing git.github.io — gitweb(1) gitweb(1) Manual PageNAMEgitweb - Git web interface (web frontend to Git repositories) SYNOPSISTo get started with gitweb, run git-instaweb(1) from a Git repository. This will configure and start your web server, and run a web browser pointing to gitweb. DESCRIPTIONGitweb provides a web interface to Git repositories. Its features include:
See https://repo.or.cz/w/git.git/tree/HEAD:/gitweb/ for gitweb source code, browsed using gitweb itself. CONFIGURATIONVarious aspects of gitweb’s behavior can be controlled through the configuration
file RepositoriesGitweb can show information from one or more Git repositories. These repositories have to be all on local filesystem, and have to share a common repository root, i.e. be all under a single parent repository (but see also the "Advanced web server setup" section, "Webserver configuration with multiple projects' root" subsection). our $projectroot = '/path/to/parent/directory'; The default value for By default all Git repositories under The name of the repository in gitweb is the path to its Projects list file formatInstead of having gitweb find repositories by scanning the filesystem
starting from $projectroot, you can provide a pre-generated list of
visible projects by setting This file uses the following format:
You can generate the projects list index file using the project_index action (the TXT link on projects list page) directly from gitweb; see also "Generating projects list using gitweb" section below. Example contents: foo.git Joe+R+Hacker+<[email protected]> foo/bar.git O+W+Ner+<[email protected]> By default this file controls only which projects are visible on projects
list page (note that entries that do not point to correctly recognized Git
repositories won’t be displayed by gitweb). Even if a project is not
visible on projects list page, you can view it nevertheless by hand-crafting
a gitweb URL. By setting Generating projects list using gitwebWe assume that GITWEB_CONFIG has its default Makefile value, namely gitweb_config.perl. Put the following in gitweb_make_index.perl file: read_config_file("gitweb_config.perl");
$projects_list = $projectroot;
Then create the following script to get list of project in the format
suitable for GITWEB_LIST build configuration variable (or
#!/bin/sh export GITWEB_CONFIG="gitweb_make_index.perl" export GATEWAY_INTERFACE="CGI/1.1" export HTTP_ACCEPT="*/*" export REQUEST_METHOD="GET" export QUERY_STRING="a=project_index" perl -- /var/www/cgi-bin/gitweb.cgi Run this script and save its output to a file. This file could then be used
as projects list file, which means that you can set Controlling access to Git repositoriesBy default all Git repositories under
Per-repository gitweb configurationYou can configure individual repositories shown in gitweb by creating file
in the You can use the following files in repository:
ACTIONS, AND URLSGitweb can use path_info (component) based URLs, or it can pass all necessary information via query parameters. The typical gitweb URLs are broken down in to five components: .../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments>
Some actions require or allow to specify two revisions, and sometimes even two pathnames. In most general form such path_info (component) based gitweb URL looks like this: .../gitweb.cgi/<repo>/<action>/<revision-from>:/<path-from>..<revision-to>:/<path-to>?<arguments> Each action is implemented as a subroutine, and must be present in %actions hash. Some actions are disabled by default, and must be turned on via feature mechanism. For example to enable blame view add the following to gitweb configuration file: $feature{'blame'}{'default'} = [1];
Actions:The standard actions are:
WEBSERVER CONFIGURATIONThis section explains how to configure some common webservers to run gitweb. In
all cases, If you’ve configured a web server that isn’t listed here for gitweb, please send in the instructions so they can be included in a future release. Apache as CGIApache must be configured to support CGI scripts in the directory in
which gitweb is installed. Let’s assume that it is ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
Options Indexes FollowSymlinks ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
With that configuration the full path to browse repositories would be: http://server/cgi-bin/gitweb.cgi Apache with mod_perl, via ModPerl::RegistryYou can use mod_perl with gitweb. You must install Apache::Registry (for mod_perl 1.x) or ModPerl::Registry (for mod_perl 2.x) to enable this support. Assuming that gitweb is installed to Alias /perl "/var/www/perl"
<Directory "/var/www/perl">
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options Indexes FollowSymlinks +ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
With that configuration the full path to browse repositories would be: http://server/perl/gitweb.cgi Apache with FastCGIGitweb works with Apache and FastCGI. First you need to rename, copy
or symlink gitweb.cgi to gitweb.fcgi. Let’s assume that gitweb is
installed in FastCgiServer /usr/share/gitweb/gitweb.cgi
ScriptAlias /gitweb /usr/share/gitweb/gitweb.cgi
Alias /gitweb/static /usr/share/gitweb/static
<Directory /usr/share/gitweb/static>
SetHandler default-handler
</Directory>
With that configuration the full path to browse repositories would be: http://server/gitweb ADVANCED WEB SERVER SETUPAll of those examples use request rewriting, and need Single URL for gitweb and for fetchingIf you want to have one URL for both gitweb and your <VirtualHost *:80>
ServerName git.example.org
DocumentRoot /pub/git
SetEnv GITWEB_CONFIG /etc/gitweb.conf
# turning on mod rewrite
RewriteEngine on
# make the front page an internal rewrite to the gitweb script
RewriteRule ^/$ /cgi-bin/gitweb.cgi
# make access for "dumb clients" work
RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \
/cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
</VirtualHost>
The above configuration expects your public repositories to live under
Setting the environment variable If you use the rewrite rules from the example you might also need
something like the following in your gitweb configuration file
( @stylesheets = ("/some/absolute/path/gitweb.css");
$my_uri = "/";
$home_link = "/";
$per_request_config = 1;
Nowadays though gitweb should create HTML base tag when needed (to set base URI for relative links), so it should work automatically. Webserver configuration with multiple projects' rootIf you want to use gitweb with several project roots you can edit your Apache virtual host and gitweb configuration files in the following way. The virtual host configuration (in Apache configuration file) should look like this: <VirtualHost *:80>
ServerName git.example.org
DocumentRoot /pub/git
SetEnv GITWEB_CONFIG /etc/gitweb.conf
# turning on mod rewrite
RewriteEngine on
# make the front page an internal rewrite to the gitweb script
RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT]
# look for a public_git directory in unix users' home
# http://git.example.org/~<user>/
RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
[QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
# http://git.example.org/+<user>/
#RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
[QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
# http://git.example.org/user/<user>/
#RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
[QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
# defined list of project roots
RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
[QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT]
RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
[QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT]
# make access for "dumb clients" work
RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \
/cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
</VirtualHost>
Here actual project root is passed to gitweb via $projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";
Note that this requires to be set for each request, so either
These configurations enable two things. First, each unix user (<user>) of
the server will be able to browse through gitweb Git repositories found in
http://git.example.org/~<user>/ If you do not want this feature on your server just remove the second rewrite rule. If you already use Second, repositories found in PATH_INFO usageIf you enable PATH_INFO usage in gitweb by putting $feature{'pathinfo'}{'default'} = [1];
in your gitweb configuration file, it is possible to set up your server so that it consumes and produces URLs in the form http://git.example.com/project.git/shortlog/sometag i.e. without gitweb.cgi part, by using a configuration such as the
following. This configuration assumes that <VirtualHost *:80>
ServerAlias git.example.com
DocumentRoot /var/www/gitweb
<Directory /var/www/gitweb>
Options ExecCGI
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
</Directory>
</VirtualHost>
The rewrite rule guarantees that existing static files will be properly served, whereas any other URL will be passed to gitweb as PATH_INFO parameter. Notice that in this case you don’t need special settings for
<VirtualHost *:80>
ServerAlias git.example.com
DocumentRoot /var/www/gitweb
AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3
<Directory /var/www/gitweb>
Options ExecCGI
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
</Directory>
</VirtualHost>
The additional AliasMatch makes it so that http://git.example.com/project.git will give raw access to the project’s Git dir (so that the project can be cloned), while http://git.example.com/project will provide human-friendly gitweb access. This solution is not 100% bulletproof, in the sense that if some project has
a named ref (branch, tag) starting with http://git.example.com/project/command/abranch..git/abranch will fail with a 404 error. BUGSPlease report any bugs or feature requests to [email protected], putting "gitweb" in the subject of email. SEE ALSO
GITPart of the git(1) suite |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |