7 From the git version 1.4.0 gitweb is bundled with git.
10 Runtime gitweb configuration
11 ----------------------------
13 You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
14 (defaults to 'gitweb_config.perl' in the same directory as the CGI), and
15 as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
16 The most notable thing that is not configurable at compile time are the
17 optional features, stored in the '%features' variable.
19 Ultimate description on how to reconfigure the default features setting
20 in your `GITWEB_CONFIG` or per-project in `project.git/config` can be found
21 as comments inside 'gitweb.cgi'.
23 See also the "Gitweb config file" (with an example of config file), and
24 the "Gitweb repositories" sections in INSTALL file for gitweb.
27 The gitweb config file is a fragment of perl code. You can set variables
28 using "our $variable = value"; text from "#" character until the end
29 of a line is ignored. See perlsyn(1) man page for details.
31 Below is the list of variables which you might want to set in gitweb config.
32 See the top of 'gitweb.cgi' for the full list of variables and their
35 Gitweb config file variables
36 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 You can set, among others, the following variables in gitweb config files
39 (with the exception of $projectroot and $projects_list this list does
40 not include variables usually directly set during build):
42 Core git executable to use. By default set to "$GIT_BINDIR/git", which
43 in turn is by default set to "$(bindir)/git". If you use git from binary
44 package, set this to "/usr/bin/git". This can just be "git" if your
45 webserver has a sensible PATH. If you have multiple git versions
46 installed it can be used to choose which one to use.
48 Gitweb version, set automatically when creating gitweb.cgi from
49 gitweb.perl. You might want to modify it if you are running modified
52 Absolute filesystem path which will be prepended to project path;
53 the path to repository is $projectroot/$project. Set to
54 $GITWEB_PROJECTROOT during installation. This variable have to be
55 set correctly for gitweb to find repositories.
57 Source of projects list, either directory to scan, or text file
58 with list of repositories (in the "<URI-encoded repository path> SP
59 <URI-encoded repository owner>" line format; actually there can be
60 any sequence of whitespace in place of space (SP)). Set to
61 $GITWEB_LIST during installation. If empty, $projectroot is used
62 to scan for repositories.
64 Full URL and absolute URL of gitweb script;
65 in earlier versions of gitweb you might have need to set those
66 variables, now there should be no need to do it. See
67 $per_request_config if you need to set them still.
69 Base URL for relative URLs in pages generated by gitweb,
70 (e.g. $logo, $favicon, @stylesheets if they are relative URLs),
71 needed and used only for URLs with nonempty PATH_INFO via
72 <base href="$base_url">. Usually gitweb sets its value correctly,
73 and there is no need to set this variable, e.g. to $my_uri or "/".
74 See $per_request_config if you need to set it anyway.
76 Target of the home link on top of all pages (the first part of view
77 "breadcrumbs"). By default set to absolute URI of a page ($my_uri).
79 List of URIs of stylesheets (relative to base URI of a page). You
80 might specify more than one stylesheet, for example use gitweb.css
81 as base, with site specific modifications in separate stylesheet
82 to make it easier to upgrade gitweb. You can add 'site' stylesheet
84 push @stylesheets, "gitweb-site.css";
85 in the gitweb config file.
86 * $logo_url, $logo_label
87 URI and label (title) of GIT logo link (or your site logo, if you choose
88 to use different logo image). By default they point to git homepage;
89 in the past they pointed to git documentation at www.kernel.org.
90 * $projects_list_description_width
91 The width (in characters) of the projects list "Description" column.
92 Longer descriptions will be cut (trying to cut at word boundary);
93 full description is available as 'title' attribute (usually shown on
94 mouseover). By default set to 25, which might be too small if you
95 use long project descriptions.
96 * $projects_list_group_categories
97 Enables the grouping of projects by category on the project list page.
98 The category of a project is determined by the $GIT_DIR/category
99 file or the 'gitweb.category' variable in its repository configuration.
101 * $project_list_default_category
102 Default category for projects for which none is specified. If set
103 to the empty string, such projects will remain uncategorized and
104 listed at the top, above categorized projects.
106 List of git base URLs used for URL to where fetch project from, shown
107 in project summary page. Full URL is "$git_base_url/$project".
108 You can setup multiple base URLs (for example one for git:// protocol
109 access, and one for http:// "dumb" protocol access). Note that per
110 repository configuration in 'cloneurl' file, or as values of gitweb.url
112 * $default_blob_plain_mimetype
113 Default mimetype for blob_plain (raw) view, if mimetype checking
114 doesn't result in some other type; by default 'text/plain'.
115 * $default_text_plain_charset
116 Default charset for text files. If not set, web server configuration
119 File to use for (filename extension based) guessing of MIME types before
120 trying /etc/mime.types. Path, if relative, is taken currently as
121 relative to the current git repository.
123 Gitweb assumes this charset if line contains non-UTF-8 characters.
124 Fallback decoding is used without error checking, so it can be even
125 'utf-8'. Value must be valid encoding; see Encoding::Supported(3pm) man
126 page for a list. By default 'latin1', aka. 'iso-8859-1'.
128 Rename detection options for git-diff and git-diff-tree. By default
129 ('-M'); set it to ('-C') or ('-C', '-C') to also detect copies, or
130 set it to () if you don't want to have renames detection.
132 If true, some gitweb features are disabled to prevent content in
133 repositories from launching cross-site scripting (XSS) attacks. Set this
134 to true if you don't trust the content of your repositories. The default
137 Used to set the maximum load that we will still respond to gitweb queries.
138 If server load exceed this value then return "503 Service Unavailable" error.
139 Server load is taken to be 0 if gitweb cannot determine its value. Set it to
140 undefined value to turn it off. The default is 300.
142 Path to the highlight executable to use (must be the one from
143 http://www.andre-simon.de due to assumptions about parameters and output).
144 Useful if highlight is not installed on your webserver's PATH.
146 * $per_request_config
147 If set to code reference, it would be run once per each request. You can
148 set parts of configuration that change per session, e.g. by setting it to
149 sub { $ENV{GL_USER} = $cgi->remote_user || "gitweb"; }
150 Otherwise it is treated as boolean value: if true gitweb would process
151 config file once per request, if false it would process config file only
152 once. Note: $my_url, $my_uri, and $base_url are overwritten with
153 their default values before every request, so if you want to change
154 them, be sure to set this variable to true or a code reference effecting
155 the desired changes. The default is true.
157 Projects list file format
158 ~~~~~~~~~~~~~~~~~~~~~~~~~
160 Instead of having gitweb find repositories by scanning filesystem starting
161 from $projectroot (or $projects_list, if it points to directory), you can
162 provide list of projects by setting $projects_list to a text file with list
163 of projects (and some additional info). This file uses the following
166 One record (for project / repository) per line, whitespace separated fields;
167 does not support (at least for now) lines continuation (newline escaping).
168 Leading and trailing whitespace are ignored, any run of whitespace can be
169 used as field separator (rules for Perl's "split(' ', $line)"). Keyed by
170 the first field, which is project name, i.e. path to repository GIT_DIR
171 relative to $projectroot. Fields use modified URI encoding, defined in
172 RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding"
173 (see http://en.wikipedia.org/wiki/Query_string#URL_encoding), the difference
174 being that SP (' ') can be encoded as '+' (and therefore '+' has to be also
175 percent-encoded). Reserved characters are: '%' (used for encoding), '+'
176 (can be used to encode SPACE), all whitespace characters as defined in Perl,
177 including SP, TAB and LF, (used to separate fields in a record).
179 Currently list of fields is
180 * <repository path> - path to repository GIT_DIR, relative to $projectroot
181 * <repository owner> - displayed as repository owner, preferably full name,
184 You can additionally use $projects_list file to limit which repositories
185 are visible, and together with $strict_export to limit access to
186 repositories (see "Gitweb repositories" section in gitweb/INSTALL).
189 Per-repository gitweb configuration
190 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192 You can also configure individual repositories shown in gitweb by creating
193 file in the GIT_DIR of git repository, or by setting some repo configuration
194 variable (in GIT_DIR/config).
196 You can use the following files in repository:
198 A .html file (HTML fragment) which is included on the gitweb project
199 summary page inside <div> block element. You can use it for longer
200 description of a project, to provide links (for example to project's
201 homepage), etc. This is recognized only if XSS prevention is off
202 ($prevent_xss is false); a way to include a readme safely when XSS
203 prevention is on may be worked out in the future.
204 * description (or gitweb.description)
205 Short (shortened by default to 25 characters in the projects list page)
206 single line description of a project (of a repository). Plain text file;
207 HTML will be escaped. By default set to
208 Unnamed repository; edit this file to name it for gitweb.
209 from the template during repository creation. You can use the
210 gitweb.description repo configuration variable, but the file takes
212 * category (or gitweb.category)
213 Singe line category of a project, used to group projects if
214 $projects_list_group_categories is enabled. By default (file and
215 configuration variable absent), uncategorized projects are put in
216 the $project_list_default_category category. You can use the
217 gitweb.category repo configuration variable, but the file takes
219 * cloneurl (or multiple-valued gitweb.url)
220 File with repository URL (used for clone and fetch), one per line.
221 Displayed in the project summary page. You can use multiple-valued
222 gitweb.url repository configuration variable for that, but the file
225 You can use the gitweb.owner repository configuration variable to set
226 repository's owner. It is displayed in the project list and summary
227 page. If it's not set, filesystem directory's owner is used
228 (via GECOS field / real name field from getpwiud(3)).
229 * various gitweb.* config variables (in config)
230 Read description of %feature hash for detailed list, and some
234 Webserver configuration
235 -----------------------
237 If you want to have one URL for both gitweb and your http://
238 repositories, you can configure apache like this:
241 ServerName git.example.org
242 DocumentRoot /pub/git
243 SetEnv GITWEB_CONFIG /etc/gitweb.conf
245 # turning on mod rewrite
248 # make the front page an internal rewrite to the gitweb script
249 RewriteRule ^/$ /cgi-bin/gitweb.cgi
251 # make access for "dumb clients" work
252 RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
255 The above configuration expects your public repositories to live under
256 /pub/git and will serve them as http://git.domain.org/dir-under-pub-git,
257 both as cloneable GIT URL and as browseable gitweb interface.
258 If you then start your git-daemon with --base-path=/pub/git --export-all
259 then you can even use the git:// URL with exactly the same path.
261 Setting the environment variable GITWEB_CONFIG will tell gitweb to use
262 the named file (i.e. in this example /etc/gitweb.conf) as a
263 configuration for gitweb. Perl variables defined in here will
264 override the defaults given at the head of the gitweb.perl (or
265 gitweb.cgi). Look at the comments in that file for information on
266 which variables and what they mean.
268 If you use the rewrite rules from the example you'll likely also need
269 something like the following in your gitweb.conf (or gitweb_config.perl) file:
271 @stylesheets = ("/some/absolute/path/gitweb.css");
276 Webserver configuration with multiple projects' root
277 ----------------------------------------------------
279 If you want to use gitweb with several project roots you can edit your apache
280 virtual host and gitweb.conf configuration files like this :
282 virtual host configuration :
285 ServerName git.example.org
286 DocumentRoot /pub/git
287 SetEnv GITWEB_CONFIG /etc/gitweb.conf
289 # turning on mod rewrite
292 # make the front page an internal rewrite to the gitweb script
293 RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT]
295 # look for a public_git folder in unix users' home
296 # http://git.example.org/~<user>/
297 RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
299 # http://git.example.org/+<user>/
300 #RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
302 # http://git.example.org/user/<user>/
303 #RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
305 # defined list of project roots
306 RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT]
307 RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT]
309 # make access for "dumb clients" work
310 RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
313 gitweb.conf configuration :
315 $projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";
317 These configurations enable two things. First, each unix user (<user>) of the
318 server will be able to browse through gitweb git repositories found in
319 ~/public_git/ with the following url : http://git.example.org/~<user>/
321 If you do not want this feature on your server just remove the second rewrite rule.
323 If you already use mod_userdir in your virtual host or you don't want to use
324 the '~' as first character just comment or remove the second rewrite rule and
325 uncomment one of the following according to what you want.
327 Second, repositories found in /pub/scm/ and /var/git/ will be accesible
328 through http://git.example.org/scm/ and http://git.example.org/var/.
329 You can add as many project roots as you want by adding rewrite rules like the
330 third and the fourth.
334 -----------------------
335 If you enable PATH_INFO usage in gitweb by putting
337 $feature{'pathinfo'}{'default'} = [1];
339 in your gitweb.conf, it is possible to set up your server so that it
340 consumes and produces URLs in the form
342 http://git.example.com/project.git/shortlog/sometag
344 by using a configuration such as the following, that assumes that
345 /var/www/gitweb is the DocumentRoot of your webserver, and that it
346 contains the gitweb.cgi script and complementary static files
347 (stylesheet, favicon):
350 ServerAlias git.example.com
352 DocumentRoot /var/www/gitweb
354 <Directory /var/www/gitweb>
356 AddHandler cgi-script cgi
358 DirectoryIndex gitweb.cgi
361 RewriteCond %{REQUEST_FILENAME} !-f
362 RewriteCond %{REQUEST_FILENAME} !-d
363 RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
367 The rewrite rule guarantees that existing static files will be properly
368 served, whereas any other URL will be passed to gitweb as PATH_INFO
371 Notice that in this case you don't need special settings for
372 @stylesheets, $my_uri and $home_link, but you lose "dumb client" access
373 to your project .git dirs. A possible workaround for the latter is the
374 following: in your project root dir (e.g. /pub/git) have the projects
375 named without a .git extension (e.g. /pub/git/project instead of
376 /pub/git/project.git) and configure Apache as follows:
379 ServerAlias git.example.com
381 DocumentRoot /var/www/gitweb
383 AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3
384 <Directory /var/www/gitweb>
386 AddHandler cgi-script cgi
388 DirectoryIndex gitweb.cgi
391 RewriteCond %{REQUEST_FILENAME} !-f
392 RewriteCond %{REQUEST_FILENAME} !-d
393 RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
397 The additional AliasMatch makes it so that
399 http://git.example.com/project.git
401 will give raw access to the project's git dir (so that the project can
404 http://git.example.com/project
406 will provide human-friendly gitweb access.
408 This solution is not 100% bulletproof, in the sense that if some project
409 has a named ref (branch, tag) starting with 'git/', then paths such as
411 http://git.example.com/project/command/abranch..git/abranch
413 will fail with a 404 error.
417 Originally written by:
418 Kay Sievers <kay.sievers@vrfy.org>
420 Any comment/question/concern to:
421 Git mailing list <git@vger.kernel.org>