gitweb
Browse Git repositories via a web interface
SYNOPSIS
gitweb.cgi (executed by a web server, e.g., Apache or Nginx)
Behavior is determined by configuration variables set in gitweb.conf
or environment variables.
PARAMETERS
$projectroot
Specifies the base directory where Git repositories are located. gitweb searches for repositories in this directory and its subdirectories.
$baseurl
Sets the base URL for the gitweb instance, used for generating absolute URLs in the web interface.
$export_ok
Boolean variable. If true, only repositories with a file named git-daemon-export-ok
(or equivalent for http.gitweb.enabled) are displayed. Useful for controlling visibility.
$allow_override
Boolean variable. If true, allows project-specific configuration overrides (e.g., in .git/gitweb/project.conf
) to customize individual repository views.
$site_name
A string that defines the title displayed in the gitweb header, typically the name of the Git hosting site.
$home_text
Specifies the path to a text file whose content will be displayed on the gitweb project list homepage. Supports basic HTML.
$features{'feature_name'}
A hash used to enable or disable various gitweb features, such as blame
(blame view), snapshot
(tarball downloads), search
(commit message search), gravatar
(user avatars), etc. Each feature can be set to 1 (enable) or 0 (disable).
$logo
Path to a logo image file to be displayed in the gitweb header.
$favicon
Path to a favicon image file for the website.
$stylesheet
Path to a custom CSS stylesheet to override default gitweb styles.
DESCRIPTION
gitweb is a Perl CGI (Common Gateway Interface) script that provides a web-based interface for browsing Git repositories. It allows users to view commit history, file contents, diffs, branches, tags, and more, all through a standard web browser. Typically, gitweb is configured to run with a web server like Apache or Nginx, which executes the script when a user accesses its URL. It offers a read-only view of repositories, making it suitable for publicly exposing Git projects without allowing direct push access. Its behavior and appearance are highly configurable through a dedicated configuration file, gitweb.conf
, which defines various options like the project root directory, enabled features, and theme settings. It's a fundamental tool for many self-hosted Git instances, providing a simple yet powerful way to explore repositories.
CAVEATS
gitweb relies heavily on correct web server configuration (e.g., Apache's ScriptAlias
or Nginx's fastcgi_pass
directives) to function properly. Misconfigurations can lead to broken links or security vulnerabilities.
It is primarily a read-only interface; it does not provide mechanisms for pushing commits or managing user access beyond visibility controls.
Performance can be an issue for very large instances with thousands of repositories or extremely active repositories if the web server and underlying file system are not adequately tuned.
CONFIGURATION FILE (GITWEB.CONF)
The primary way to configure gitweb is through the gitweb.conf
file. This file, typically located in /etc/gitweb.conf
or determined by the web server configuration, is a Perl script that sets global variables controlling gitweb's behavior, appearance, and features. It's crucial for defining repository paths, enabling features like snapshot downloads or search, and customizing branding.
SECURITY CONSIDERATIONS
As a CGI script, gitweb execution environment should be carefully secured. Ensure the web server executes the script with appropriate permissions and that the $projectroot
and other paths are correctly configured to prevent unauthorized access to sensitive files. It's recommended to run it in a
chroot environment or with minimal privileges if possible. Always keep gitweb and the underlying Git installation up to date to benefit from security fixes.
HISTORY
gitweb was an early and integral component of the Git project, providing a simple yet effective way to browse Git repositories over the web. It was originally developed by Kay Sievers and has since been maintained and extended by the broader Git development community. Its development started around 2005, shortly after Git itself, to provide a readily available web interface for projects hosted with Git. Before the rise of more complex platforms like GitHub or GitLab, gitweb was a standard choice for self-hosting public Git repositories, and it continues to be a robust, lightweight option for those who prefer a minimalist web interface directly integrated with their Git installations.
SEE ALSO
git(1), git-daemon(1), git-config(1), git-repo(7)