7 From the git version 1.4.0 gitweb is bundled with git.
10 How to configure gitweb for your local system
11 ---------------------------------------------
13 See also the "Build time configuration" section in the INSTALL
14 file for gitweb (in gitweb/INSTALL).
16 You can specify the following configuration variables when building GIT:
18 Points where to find the git executable. You should set it up to
19 the place where the git binary was installed (usually /usr/bin) if you
20 don't install git from sources together with gitweb. [Default: $(bindir)]
22 Shown in the title of all generated pages, defaults to the server name
23 (SERVER_NAME CGI environment variable) if not set. [No default]
25 The root directory for all projects shown by gitweb. Must be set
26 correctly for gitweb to find repositories to display. See also
27 "Gitweb repositories" in the INSTALL file for gitweb. [Default: /pub/git]
28 * GITWEB_PROJECT_MAXDEPTH
29 The filesystem traversing limit for getting the project list; the number
30 is taken as depth relative to the projectroot. It is used when
31 GITWEB_LIST is a directory (or is not set; then project root is used).
32 Is is meant to speed up project listing on large work trees by limiting
33 search depth. [Default: 2007]
35 Points to a directory to scan for projects (defaults to project root
36 if not set / if empty) or to a file with explicit listing of projects
37 (together with projects' ownership). See "Generating projects list
38 using gitweb" in INSTALL file for gitweb to find out how to generate
39 such file from scan of a directory. [No default, which means use root
40 directory for projects]
42 Show repository only if this file exists (in repository). Only
43 effective if this variable evaluates to true. [No default / Not set]
44 * GITWEB_STRICT_EXPORT
45 Only allow viewing of repositories also shown on the overview page.
46 This for example makes GITWEB_EXPORT_OK to decide if repository is
47 available and not only if it is shown. If GITWEB_LIST points to
48 file with list of project, only those repositories listed would be
49 available for gitweb. [No default]
51 Points to an .html file which is included on the gitweb project
52 overview page ('projects_list' view), if it exists. Relative to
53 gitweb.cgi script. [Default: indextext.html]
55 Filename of html text to include at top of each page. Relative to
56 gitweb.cgi script. [No default]
58 Filename of html text to include at bottom of each page. Relative to
59 gitweb.cgi script. [No default]
60 * GITWEB_HOME_LINK_STR
61 String of the home link on top of all pages, leading to $home_link
62 (usually main gitweb page, which means projects list). Used as first
63 part of gitweb view "breadcrumb trail": <home> / <project> / <view>.
66 Name of your site or organization to appear in page titles. Set it
67 to something descriptive for clearer bookmarks etc. If not set
68 (if empty) gitweb uses "$SERVER_NAME Git", or "Untitled Git" if
69 SERVER_NAME CGI environment variable is not set (e.g. if running
70 gitweb as standalone script). [No default]
72 Git base URLs used for URL to where fetch project from, i.e. full
73 URL is "$git_base_url/$project". Shown on projects summary page.
74 Repository URL for project can be also configured per repository; this
75 takes precedence over URLs composed from base URL and a project name.
76 Note that you can setup multiple base URLs (for example one for
77 git:// protocol access, another for http:// access) from the gitweb
78 config file. [No default]
80 Points to the location where you put gitweb.css on your web server
81 (or to be more generic, the URI of gitweb stylesheet). Relative to the
82 base URI of gitweb. Note that you can setup multiple stylesheets from
83 the gitweb config file. [Default: static/gitweb.css (or
84 static/gitweb.min.css if the CSSMIN variable is defined / CSS minifier
87 Points to the location where you put git-logo.png on your web server
88 (or to be more generic URI of logo, 72x27 size, displayed in top right
89 corner of each gitweb page, and used as logo for Atom feed). Relative
90 to base URI of gitweb. [Default: static/git-logo.png]
92 Points to the location where you put git-favicon.png on your web server
93 (or to be more generic URI of favicon, assumed to be image/png type;
94 web browsers that support favicons (website icons) may display them
95 in the browser's URL bar and next to site name in bookmarks). Relative
96 to base URI of gitweb. [Default: static/git-favicon.png]
98 Points to the location where you put gitweb.js on your web server
99 (or to be more generic URI of JavaScript code used by gitweb).
100 Relative to base URI of gitweb. [Default: static/gitweb.js (or
101 static/gitweb.min.js if JSMIN build variable is defined / JavaScript
104 This Perl file will be loaded using 'do' and can be used to override any
105 of the options above as well as some other options -- see the "Runtime
106 gitweb configuration" section below, and top of 'gitweb.cgi' for their
107 full list and description. If the environment variable GITWEB_CONFIG
108 is set when gitweb.cgi is executed, then the file specified in the
109 environment variable will be loaded instead of the file specified
110 when gitweb.cgi was created. [Default: gitweb_config.perl]
111 * GITWEB_CONFIG_SYSTEM
112 This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
113 does not exist. If the environment variable GITWEB_CONFIG_SYSTEM is set
114 when gitweb.cgi is executed, then the file specified in the environment
115 variable will be loaded instead of the file specified when gitweb.cgi was
116 created. [Default: /etc/gitweb.conf]
118 Path to the highlight executable to use (must be the one from
119 http://www.andre-simon.de due to assumptions about parameters and output).
120 Useful if highlight is not installed on your webserver's PATH.
124 Runtime gitweb configuration
125 ----------------------------
127 You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
128 (defaults to 'gitweb_config.perl' in the same directory as the CGI), and
129 as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
130 The most notable thing that is not configurable at compile time are the
131 optional features, stored in the '%features' variable.
133 Ultimate description on how to reconfigure the default features setting
134 in your `GITWEB_CONFIG` or per-project in `project.git/config` can be found
135 as comments inside 'gitweb.cgi'.
137 See also the "Gitweb config file" (with an example of config file), and
138 the "Gitweb repositories" sections in INSTALL file for gitweb.
141 The gitweb config file is a fragment of perl code. You can set variables
142 using "our $variable = value"; text from "#" character until the end
143 of a line is ignored. See perlsyn(1) man page for details.
145 Below is the list of variables which you might want to set in gitweb config.
146 See the top of 'gitweb.cgi' for the full list of variables and their
149 Gitweb config file variables
150 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152 You can set, among others, the following variables in gitweb config files
153 (with the exception of $projectroot and $projects_list this list does
154 not include variables usually directly set during build):
156 Core git executable to use. By default set to "$GIT_BINDIR/git", which
157 in turn is by default set to "$(bindir)/git". If you use git from binary
158 package, set this to "/usr/bin/git". This can just be "git" if your
159 webserver has a sensible PATH. If you have multiple git versions
160 installed it can be used to choose which one to use.
162 Gitweb version, set automatically when creating gitweb.cgi from
163 gitweb.perl. You might want to modify it if you are running modified
166 Absolute filesystem path which will be prepended to project path;
167 the path to repository is $projectroot/$project. Set to
168 $GITWEB_PROJECTROOT during installation. This variable have to be
169 set correctly for gitweb to find repositories.
171 Source of projects list, either directory to scan, or text file
172 with list of repositories (in the "<URI-encoded repository path> SP
173 <URI-encoded repository owner>" line format; actually there can be
174 any sequence of whitespace in place of space (SP)). Set to
175 $GITWEB_LIST during installation. If empty, $projectroot is used
176 to scan for repositories.
178 Full URL and absolute URL of gitweb script;
179 in earlier versions of gitweb you might have need to set those
180 variables, now there should be no need to do it.
182 Base URL for relative URLs in pages generated by gitweb,
183 (e.g. $logo, $favicon, @stylesheets if they are relative URLs),
184 needed and used only for URLs with nonempty PATH_INFO via
185 <base href="$base_url">. Usually gitweb sets its value correctly,
186 and there is no need to set this variable, e.g. to $my_uri or "/".
188 Target of the home link on top of all pages (the first part of view
189 "breadcrumbs"). By default set to absolute URI of a page ($my_uri).
191 List of URIs of stylesheets (relative to base URI of a page). You
192 might specify more than one stylesheet, for example use gitweb.css
193 as base, with site specific modifications in separate stylesheet
194 to make it easier to upgrade gitweb. You can add 'site' stylesheet
196 push @stylesheets, "gitweb-site.css";
197 in the gitweb config file.
198 * $logo_url, $logo_label
199 URI and label (title) of GIT logo link (or your site logo, if you choose
200 to use different logo image). By default they point to git homepage;
201 in the past they pointed to git documentation at www.kernel.org.
202 * $projects_list_description_width
203 The width (in characters) of the projects list "Description" column.
204 Longer descriptions will be cut (trying to cut at word boundary);
205 full description is available as 'title' attribute (usually shown on
206 mouseover). By default set to 25, which might be too small if you
207 use long project descriptions.
209 List of git base URLs used for URL to where fetch project from, shown
210 in project summary page. Full URL is "$git_base_url/$project".
211 You can setup multiple base URLs (for example one for git:// protocol
212 access, and one for http:// "dumb" protocol access). Note that per
213 repository configuration in 'cloneurl' file, or as values of gitweb.url
215 * $default_blob_plain_mimetype
216 Default mimetype for blob_plain (raw) view, if mimetype checking
217 doesn't result in some other type; by default 'text/plain'.
218 * $default_text_plain_charset
219 Default charset for text files. If not set, web server configuration
222 File to use for (filename extension based) guessing of MIME types before
223 trying /etc/mime.types. Path, if relative, is taken currently as
224 relative to the current git repository.
226 Gitweb assumes this charset if line contains non-UTF-8 characters.
227 Fallback decoding is used without error checking, so it can be even
228 'utf-8'. Value must be valid encoding; see Encoding::Supported(3pm) man
229 page for a list. By default 'latin1', aka. 'iso-8859-1'.
231 Rename detection options for git-diff and git-diff-tree. By default
232 ('-M'); set it to ('-C') or ('-C', '-C') to also detect copies, or
233 set it to () if you don't want to have renames detection.
235 If true, some gitweb features are disabled to prevent content in
236 repositories from launching cross-site scripting (XSS) attacks. Set this
237 to true if you don't trust the content of your repositories. The default
240 Used to set the maximum load that we will still respond to gitweb queries.
241 If server load exceed this value then return "503 Service Unavailable" error.
242 Server load is taken to be 0 if gitweb cannot determine its value. Set it to
243 undefined value to turn it off. The default is 300.
245 Path to the highlight executable to use (must be the one from
246 http://www.andre-simon.de due to assumptions about parameters and output).
247 Useful if highlight is not installed on your webserver's PATH.
250 If true, gitweb would use caching to speed up generating response.
251 Currently supported is only output (response) caching. See "Gitweb caching"
252 section below for details on how to configure and customize caching.
253 The default is false (caching is disabled).
256 Projects list file format
257 ~~~~~~~~~~~~~~~~~~~~~~~~~
259 Instead of having gitweb find repositories by scanning filesystem starting
260 from $projectroot (or $projects_list, if it points to directory), you can
261 provide list of projects by setting $projects_list to a text file with list
262 of projects (and some additional info). This file uses the following
265 One record (for project / repository) per line, whitespace separated fields;
266 does not support (at least for now) lines continuation (newline escaping).
267 Leading and trailing whitespace are ignored, any run of whitespace can be
268 used as field separator (rules for Perl's "split(' ', $line)"). Keyed by
269 the first field, which is project name, i.e. path to repository GIT_DIR
270 relative to $projectroot. Fields use modified URI encoding, defined in
271 RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding"
272 (see http://en.wikipedia.org/wiki/Query_string#URL_encoding), the difference
273 being that SP (' ') can be encoded as '+' (and therefore '+' has to be also
274 percent-encoded). Reserved characters are: '%' (used for encoding), '+'
275 (can be used to encode SPACE), all whitespace characters as defined in Perl,
276 including SP, TAB and LF, (used to separate fields in a record).
278 Currently list of fields is
279 * <repository path> - path to repository GIT_DIR, relative to $projectroot
280 * <repository owner> - displayed as repository owner, preferably full name,
283 You can additionally use $projects_list file to limit which repositories
284 are visible, and together with $strict_export to limit access to
285 repositories (see "Gitweb repositories" section in gitweb/INSTALL).
288 Per-repository gitweb configuration
289 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291 You can also configure individual repositories shown in gitweb by creating
292 file in the GIT_DIR of git repository, or by setting some repo configuration
293 variable (in GIT_DIR/config).
295 You can use the following files in repository:
297 A .html file (HTML fragment) which is included on the gitweb project
298 summary page inside <div> block element. You can use it for longer
299 description of a project, to provide links (for example to project's
300 homepage), etc. This is recognized only if XSS prevention is off
301 ($prevent_xss is false); a way to include a readme safely when XSS
302 prevention is on may be worked out in the future.
303 * description (or gitweb.description)
304 Short (shortened by default to 25 characters in the projects list page)
305 single line description of a project (of a repository). Plain text file;
306 HTML will be escaped. By default set to
307 Unnamed repository; edit this file to name it for gitweb.
308 from the template during repository creation. You can use the
309 gitweb.description repo configuration variable, but the file takes
311 * cloneurl (or multiple-valued gitweb.url)
312 File with repository URL (used for clone and fetch), one per line.
313 Displayed in the project summary page. You can use multiple-valued
314 gitweb.url repository configuration variable for that, but the file
317 You can use the gitweb.owner repository configuration variable to set
318 repository's owner. It is displayed in the project list and summary
319 page. If it's not set, filesystem directory's owner is used
320 (via GECOS field / real name field from getpwiud(3)).
321 * various gitweb.* config variables (in config)
322 Read description of %feature hash for detailed list, and some
329 Currently gitweb supports only output (HTTP response) caching, similar
330 to the one used on http://git.kernel.org. To turn it on, set
331 $caching_enabled variable to true value in gitweb config file, i.e.:
333 our $caching_enabled = 1;
335 You can choose which caching engine should gitweb use by setting $cache
336 variable to _initialized_ instance of cache interface, e.g.:
339 our $cache = CHI->new( driver => 'Memcached',
340 servers => [ "10.0.0.15:11211", "10.0.0.15:11212" ],
341 l1_cache => { driver => 'FastMmap', root_dir => '/var/cache/gitweb' }
344 Alternatively you can set $cache variable to the name of cache class,
347 our $cache = 'Cache::FileCache';
349 In this case caching engine should support Cache::Cache or CHI names for
350 cache config (see below), and ignore unrecognized options. Such caching
351 engine should also implement (at least) ->get($key) and ->set($key, $data)
352 methods (Cache::Cache and CHI compatible interface).
354 You can set $cache to 'GitwebCache::SimpleFileCache' if you don't want
355 to use locking, but then some advanced features, like generating data in
356 background, wouldn't work because they require locking.
358 If $cache is left unset (if it is left undefined), then gitweb would use
359 GitwebCache::FileCacheWithLocking as caching engine. This engine is 'dumb' (but
360 fast) file based caching layer, currently without any support for cache size
361 limiting, or even removing expired / grossly expired entries. It has
362 therefore the downside of requiring a huge amount of disk space if there are
363 a number of repositories involved. It is not uncommon for git.kernel.org to
364 have on the order of 80G - 120G accumulate over the course of a few months.
365 It is therefore recommended that the cache directory be periodically
366 completely deleted; this operation is safe to perform. Suggested mechanism
367 (substitute $cachedir for actual path to gitweb cache):
369 # mv $cachedir $cachedir.flush && mkdir $cachedir && rm -rf $cachedir.flush
371 Site-wide cache options are defined in %cache_options hash. Those options
372 apply only when $cache is unset (GitwebCache::SimpleFileCache is used), or
373 if $cache is name of cache class (e.g. $cache = 'Cache::FileCache'). You
374 can override cache options in gitweb config, e.g.:
376 $cache_options{'expires_in'} = 60; # 60 seconds = 1 minute
378 Please read comments for %cache_options entries in gitweb/gitweb.perl for
379 description of available cache options.
382 Webserver configuration
383 -----------------------
385 If you want to have one URL for both gitweb and your http://
386 repositories, you can configure apache like this:
389 ServerName git.example.org
390 DocumentRoot /pub/git
391 SetEnv GITWEB_CONFIG /etc/gitweb.conf
393 # turning on mod rewrite
396 # make the front page an internal rewrite to the gitweb script
397 RewriteRule ^/$ /cgi-bin/gitweb.cgi
399 # make access for "dumb clients" work
400 RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
403 The above configuration expects your public repositories to live under
404 /pub/git and will serve them as http://git.domain.org/dir-under-pub-git,
405 both as cloneable GIT URL and as browseable gitweb interface.
406 If you then start your git-daemon with --base-path=/pub/git --export-all
407 then you can even use the git:// URL with exactly the same path.
409 Setting the environment variable GITWEB_CONFIG will tell gitweb to use
410 the named file (i.e. in this example /etc/gitweb.conf) as a
411 configuration for gitweb. Perl variables defined in here will
412 override the defaults given at the head of the gitweb.perl (or
413 gitweb.cgi). Look at the comments in that file for information on
414 which variables and what they mean.
416 If you use the rewrite rules from the example you'll likely also need
417 something like the following in your gitweb.conf (or gitweb_config.perl) file:
419 @stylesheets = ("/some/absolute/path/gitweb.css");
424 Webserver configuration with multiple projects' root
425 ----------------------------------------------------
427 If you want to use gitweb with several project roots you can edit your apache
428 virtual host and gitweb.conf configuration files like this :
430 virtual host configuration :
433 ServerName git.example.org
434 DocumentRoot /pub/git
435 SetEnv GITWEB_CONFIG /etc/gitweb.conf
437 # turning on mod rewrite
440 # make the front page an internal rewrite to the gitweb script
441 RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT]
443 # look for a public_git folder in unix users' home
444 # http://git.example.org/~<user>/
445 RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
447 # http://git.example.org/+<user>/
448 #RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
450 # http://git.example.org/user/<user>/
451 #RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
453 # defined list of project roots
454 RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT]
455 RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT]
457 # make access for "dumb clients" work
458 RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
461 gitweb.conf configuration :
463 $projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";
465 These configurations enable two things. First, each unix user (<user>) of the
466 server will be able to browse through gitweb git repositories found in
467 ~/public_git/ with the following url : http://git.example.org/~<user>/
469 If you do not want this feature on your server just remove the second rewrite rule.
471 If you already use mod_userdir in your virtual host or you don't want to use
472 the '~' as first character just comment or remove the second rewrite rule and
473 uncomment one of the following according to what you want.
475 Second, repositories found in /pub/scm/ and /var/git/ will be accesible
476 through http://git.example.org/scm/ and http://git.example.org/var/.
477 You can add as many project roots as you want by adding rewrite rules like the
478 third and the fourth.
482 -----------------------
483 If you enable PATH_INFO usage in gitweb by putting
485 $feature{'pathinfo'}{'default'} = [1];
487 in your gitweb.conf, it is possible to set up your server so that it
488 consumes and produces URLs in the form
490 http://git.example.com/project.git/shortlog/sometag
492 by using a configuration such as the following, that assumes that
493 /var/www/gitweb is the DocumentRoot of your webserver, and that it
494 contains the gitweb.cgi script and complementary static files
495 (stylesheet, favicon):
498 ServerAlias git.example.com
500 DocumentRoot /var/www/gitweb
502 <Directory /var/www/gitweb>
504 AddHandler cgi-script cgi
506 DirectoryIndex gitweb.cgi
509 RewriteCond %{REQUEST_FILENAME} !-f
510 RewriteCond %{REQUEST_FILENAME} !-d
511 RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
515 The rewrite rule guarantees that existing static files will be properly
516 served, whereas any other URL will be passed to gitweb as PATH_INFO
519 Notice that in this case you don't need special settings for
520 @stylesheets, $my_uri and $home_link, but you lose "dumb client" access
521 to your project .git dirs. A possible workaround for the latter is the
522 following: in your project root dir (e.g. /pub/git) have the projects
523 named without a .git extension (e.g. /pub/git/project instead of
524 /pub/git/project.git) and configure Apache as follows:
527 ServerAlias git.example.com
529 DocumentRoot /var/www/gitweb
531 AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3
532 <Directory /var/www/gitweb>
534 AddHandler cgi-script cgi
536 DirectoryIndex gitweb.cgi
539 RewriteCond %{REQUEST_FILENAME} !-f
540 RewriteCond %{REQUEST_FILENAME} !-d
541 RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
545 The additional AliasMatch makes it so that
547 http://git.example.com/project.git
549 will give raw access to the project's git dir (so that the project can
552 http://git.example.com/project
554 will provide human-friendly gitweb access.
556 This solution is not 100% bulletproof, in the sense that if some project
557 has a named ref (branch, tag) starting with 'git/', then paths such as
559 http://git.example.com/project/command/abranch..git/abranch
561 will fail with a 404 error.
565 Originally written by:
566 Kay Sievers <kay.sievers@vrfy.org>
568 Any comment/question/concern to:
569 Git mailing list <git@vger.kernel.org>