logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

gitweb.1 (29512B)


  1. '\" t
  2. .\" Title: gitweb
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GITWEB" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. gitweb \- Git web interface (web frontend to Git repositories)
  32. .SH "SYNOPSIS"
  33. .sp
  34. To get started with gitweb, run \fBgit-instaweb\fR(1) from a Git repository\&. This will configure and start your web server, and run a web browser pointing to gitweb\&.
  35. .SH "DESCRIPTION"
  36. .sp
  37. Gitweb provides a web interface to Git repositories\&. Its features include:
  38. .sp
  39. .RS 4
  40. .ie n \{\
  41. \h'-04'\(bu\h'+03'\c
  42. .\}
  43. .el \{\
  44. .sp -1
  45. .IP \(bu 2.3
  46. .\}
  47. Viewing multiple Git repositories with common root\&.
  48. .RE
  49. .sp
  50. .RS 4
  51. .ie n \{\
  52. \h'-04'\(bu\h'+03'\c
  53. .\}
  54. .el \{\
  55. .sp -1
  56. .IP \(bu 2.3
  57. .\}
  58. Browsing every revision of the repository\&.
  59. .RE
  60. .sp
  61. .RS 4
  62. .ie n \{\
  63. \h'-04'\(bu\h'+03'\c
  64. .\}
  65. .el \{\
  66. .sp -1
  67. .IP \(bu 2.3
  68. .\}
  69. Viewing the contents of files in the repository at any revision\&.
  70. .RE
  71. .sp
  72. .RS 4
  73. .ie n \{\
  74. \h'-04'\(bu\h'+03'\c
  75. .\}
  76. .el \{\
  77. .sp -1
  78. .IP \(bu 2.3
  79. .\}
  80. Viewing the revision log of branches, history of files and directories, seeing what was changed, when, and by whom\&.
  81. .RE
  82. .sp
  83. .RS 4
  84. .ie n \{\
  85. \h'-04'\(bu\h'+03'\c
  86. .\}
  87. .el \{\
  88. .sp -1
  89. .IP \(bu 2.3
  90. .\}
  91. Viewing the blame/annotation details of any file (if enabled)\&.
  92. .RE
  93. .sp
  94. .RS 4
  95. .ie n \{\
  96. \h'-04'\(bu\h'+03'\c
  97. .\}
  98. .el \{\
  99. .sp -1
  100. .IP \(bu 2.3
  101. .\}
  102. Generating RSS and Atom feeds of commits, for any branch\&. The feeds are auto\-discoverable in modern web browsers\&.
  103. .RE
  104. .sp
  105. .RS 4
  106. .ie n \{\
  107. \h'-04'\(bu\h'+03'\c
  108. .\}
  109. .el \{\
  110. .sp -1
  111. .IP \(bu 2.3
  112. .\}
  113. Viewing everything that was changed in a revision, and stepping through revisions one at a time, viewing the history of the repository\&.
  114. .RE
  115. .sp
  116. .RS 4
  117. .ie n \{\
  118. \h'-04'\(bu\h'+03'\c
  119. .\}
  120. .el \{\
  121. .sp -1
  122. .IP \(bu 2.3
  123. .\}
  124. Finding commits whose commit messages match a given search term\&.
  125. .RE
  126. .sp
  127. See \m[blue]\fBhttps://repo\&.or\&.cz/w/git\&.git/tree/HEAD:/gitweb/\fR\m[] for gitweb source code, browsed using gitweb itself\&.
  128. .SH "CONFIGURATION"
  129. .sp
  130. Various aspects of gitweb\(cqs behavior can be controlled through the configuration file \fBgitweb_config\&.perl\fR or \fB/etc/gitweb\&.conf\fR\&. See the \fBgitweb.conf\fR(5) for details\&.
  131. .SS "Repositories"
  132. .sp
  133. Gitweb 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\*(Aq root" subsection)\&.
  134. .sp
  135. .if n \{\
  136. .RS 4
  137. .\}
  138. .nf
  139. our $projectroot = \*(Aq/path/to/parent/directory\*(Aq;
  140. .fi
  141. .if n \{\
  142. .RE
  143. .\}
  144. .sp
  145. The default value for \fB$projectroot\fR is \fB/pub/git\fR\&. You can change it during building gitweb via the \fBGITWEB_PROJECTROOT\fR build configuration variable\&.
  146. .sp
  147. By default all Git repositories under \fB$projectroot\fR are visible and available to gitweb\&. The list of projects is generated by default by scanning the \fB$projectroot\fR directory for Git repositories (for object databases to be more exact; gitweb is not interested in a working area, and is best suited to showing "bare" repositories)\&.
  148. .sp
  149. The name of the repository in gitweb is the path to its \fB$GIT_DIR\fR (its object database) relative to \fB$projectroot\fR\&. Therefore the repository $repo can be found at "$projectroot/$repo"\&.
  150. .SS "Projects list file format"
  151. .sp
  152. Instead of having gitweb find repositories by scanning the filesystem starting from $projectroot, you can provide a pre\-generated list of visible projects by setting \fB$projects_list\fR to point to a plain text file with a list of projects (with some additional info)\&.
  153. .sp
  154. This file uses the following format:
  155. .sp
  156. .RS 4
  157. .ie n \{\
  158. \h'-04'\(bu\h'+03'\c
  159. .\}
  160. .el \{\
  161. .sp -1
  162. .IP \(bu 2.3
  163. .\}
  164. One record (for project / repository) per line; does not support line continuation (newline escaping)\&.
  165. .RE
  166. .sp
  167. .RS 4
  168. .ie n \{\
  169. \h'-04'\(bu\h'+03'\c
  170. .\}
  171. .el \{\
  172. .sp -1
  173. .IP \(bu 2.3
  174. .\}
  175. Leading and trailing whitespace are ignored\&.
  176. .RE
  177. .sp
  178. .RS 4
  179. .ie n \{\
  180. \h'-04'\(bu\h'+03'\c
  181. .\}
  182. .el \{\
  183. .sp -1
  184. .IP \(bu 2.3
  185. .\}
  186. Whitespace separated fields; any run of whitespace can be used as field separator (rules for Perl\(cqs "\fBsplit\fR(" ",
  187. \fB$line\fR)")\&.
  188. .RE
  189. .sp
  190. .RS 4
  191. .ie n \{\
  192. \h'-04'\(bu\h'+03'\c
  193. .\}
  194. .el \{\
  195. .sp -1
  196. .IP \(bu 2.3
  197. .\}
  198. Fields use modified URI encoding, defined in RFC 3986, section 2\&.1 (Percent\-Encoding), or rather "Query string encoding" (see
  199. \m[blue]\fBhttps://en\&.wikipedia\&.org/wiki/Query_string#URL_encoding\fR\m[]), the difference being that SP (" ") can be encoded as "+" (and therefore "+" has to be also percent\-encoded)\&.
  200. .sp
  201. Reserved characters are: "%" (used for encoding), "+" (can be used to encode SPACE), all whitespace characters as defined in Perl, including SP, TAB and LF, (used to separate fields in a record)\&.
  202. .RE
  203. .sp
  204. .RS 4
  205. .ie n \{\
  206. \h'-04'\(bu\h'+03'\c
  207. .\}
  208. .el \{\
  209. .sp -1
  210. .IP \(bu 2.3
  211. .\}
  212. Currently recognized fields are:
  213. .PP
  214. <repository path>
  215. .RS 4
  216. path to repository GIT_DIR, relative to
  217. \fB$projectroot\fR
  218. .RE
  219. .PP
  220. <repository owner>
  221. .RS 4
  222. displayed as repository owner, preferably full name, or email, or both
  223. .RE
  224. .RE
  225. .sp
  226. You can generate the projects list index file using the project_index action (the \fITXT\fR link on projects list page) directly from gitweb; see also "Generating projects list using gitweb" section below\&.
  227. .sp
  228. Example contents:
  229. .sp
  230. .if n \{\
  231. .RS 4
  232. .\}
  233. .nf
  234. foo\&.git Joe+R+Hacker+<joe@example\&.com>
  235. foo/bar\&.git O+W+Ner+<owner@example\&.org>
  236. .fi
  237. .if n \{\
  238. .RE
  239. .\}
  240. .sp
  241. By default this file controls only which projects are \fBvisible\fR on projects list page (note that entries that do not point to correctly recognized Git repositories won\(cqt 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 \fB$strict_export\fR configuration variable (see \fBgitweb.conf\fR(5)) to true value you can allow viewing only of repositories also shown on the overview page (i\&.e\&. only projects explicitly listed in projects list file will be accessible)\&.
  242. .SS "Generating projects list using gitweb"
  243. .sp
  244. We assume that GITWEB_CONFIG has its default Makefile value, namely \fIgitweb_config\&.perl\fR\&. Put the following in \fIgitweb_make_index\&.perl\fR file:
  245. .sp
  246. .if n \{\
  247. .RS 4
  248. .\}
  249. .nf
  250. read_config_file("gitweb_config\&.perl");
  251. $projects_list = $projectroot;
  252. .fi
  253. .if n \{\
  254. .RE
  255. .\}
  256. .sp
  257. Then create the following script to get list of project in the format suitable for GITWEB_LIST build configuration variable (or \fB$projects_list\fR variable in gitweb config):
  258. .sp
  259. .if n \{\
  260. .RS 4
  261. .\}
  262. .nf
  263. #!/bin/sh
  264. export GITWEB_CONFIG="gitweb_make_index\&.perl"
  265. export GATEWAY_INTERFACE="CGI/1\&.1"
  266. export HTTP_ACCEPT="*/*"
  267. export REQUEST_METHOD="GET"
  268. export QUERY_STRING="a=project_index"
  269. perl \-\- /var/www/cgi\-bin/gitweb\&.cgi
  270. .fi
  271. .if n \{\
  272. .RE
  273. .\}
  274. .sp
  275. 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 \fB$projects_list\fR to its filename\&.
  276. .SS "Controlling access to Git repositories"
  277. .sp
  278. By default all Git repositories under \fB$projectroot\fR are visible and available to gitweb\&. You can however configure how gitweb controls access to repositories\&.
  279. .sp
  280. .RS 4
  281. .ie n \{\
  282. \h'-04'\(bu\h'+03'\c
  283. .\}
  284. .el \{\
  285. .sp -1
  286. .IP \(bu 2.3
  287. .\}
  288. As described in "Projects list file format" section, you can control which projects are
  289. \fBvisible\fR
  290. by selectively including repositories in projects list file, and setting
  291. \fB$projects_list\fR
  292. gitweb configuration variable to point to it\&. With
  293. \fB$strict_export\fR
  294. set, projects list file can be used to control which repositories are
  295. \fBavailable\fR
  296. as well\&.
  297. .RE
  298. .sp
  299. .RS 4
  300. .ie n \{\
  301. \h'-04'\(bu\h'+03'\c
  302. .\}
  303. .el \{\
  304. .sp -1
  305. .IP \(bu 2.3
  306. .\}
  307. You can configure gitweb to only list and allow viewing of the explicitly exported repositories, via
  308. \fB$export_ok\fR
  309. variable in gitweb config file; see
  310. \fBgitweb.conf\fR(5)
  311. manpage\&. If it evaluates to true, gitweb shows repositories only if this file named by
  312. \fB$export_ok\fR
  313. exists in its object database (if directory has the magic file named
  314. \fB$export_ok\fR)\&.
  315. .sp
  316. For example
  317. \fBgit-daemon\fR(1)
  318. by default (unless
  319. \fB\-\-export\-all\fR
  320. option is used) allows pulling only for those repositories that have
  321. \fIgit\-daemon\-export\-ok\fR
  322. file\&. Adding
  323. .sp
  324. .if n \{\
  325. .RS 4
  326. .\}
  327. .nf
  328. our $export_ok = "git\-daemon\-export\-ok";
  329. .fi
  330. .if n \{\
  331. .RE
  332. .\}
  333. .sp
  334. makes gitweb show and allow access only to those repositories that can be fetched from via
  335. \fBgit://\fR
  336. protocol\&.
  337. .RE
  338. .sp
  339. .RS 4
  340. .ie n \{\
  341. \h'-04'\(bu\h'+03'\c
  342. .\}
  343. .el \{\
  344. .sp -1
  345. .IP \(bu 2.3
  346. .\}
  347. Finally, it is possible to specify an arbitrary perl subroutine that will be called for each repository to determine if it can be exported\&. The subroutine receives an absolute path to the project (repository) as its only parameter (i\&.e\&. "$projectroot/$project")\&.
  348. .sp
  349. For example, if you use mod_perl to run the script, and have dumb HTTP protocol authentication configured for your repositories, you can use the following hook to allow access only if the user is authorized to read the files:
  350. .sp
  351. .if n \{\
  352. .RS 4
  353. .\}
  354. .nf
  355. $export_auth_hook = sub {
  356. use Apache2::SubRequest ();
  357. use Apache2::Const \-compile => qw(HTTP_OK);
  358. my $path = "$_[0]/HEAD";
  359. my $r = Apache2::RequestUtil\->request;
  360. my $sub = $r\->lookup_file($path);
  361. return $sub\->filename eq $path
  362. && $sub\->status == Apache2::Const::HTTP_OK;
  363. };
  364. .fi
  365. .if n \{\
  366. .RE
  367. .\}
  368. .RE
  369. .SS "Per\-repository gitweb configuration"
  370. .sp
  371. You can configure individual repositories shown in gitweb by creating file in the \fBGIT_DIR\fR of Git repository, or by setting some repo configuration variable (in \fBGIT_DIR/config\fR, see \fBgit-config\fR(1))\&.
  372. .sp
  373. You can use the following files in repository:
  374. .PP
  375. README\&.html
  376. .RS 4
  377. A html file (HTML fragment) which is included on the gitweb project "summary" page inside
  378. \fI<div>\fR
  379. block element\&. You can use it for longer description of a project, to provide links (for example to project\(cqs homepage), etc\&. This is recognized only if XSS prevention is off (\fB$prevent_xss\fR
  380. is false, see
  381. \fBgitweb.conf\fR(5)); a way to include a README safely when XSS prevention is on may be worked out in the future\&.
  382. .RE
  383. .PP
  384. description (or \fBgitweb\&.description\fR)
  385. .RS 4
  386. Short (shortened to
  387. \fB$projects_list_description_width\fR
  388. in the projects list page, which is 25 characters by default; see
  389. \fBgitweb.conf\fR(5)) single line description of a project (of a repository)\&. Plain text file; HTML will be escaped\&. By default set to
  390. .sp
  391. .if n \{\
  392. .RS 4
  393. .\}
  394. .nf
  395. Unnamed repository; edit this file to name it for gitweb\&.
  396. .fi
  397. .if n \{\
  398. .RE
  399. .\}
  400. .sp
  401. from the template during repository creation, usually installed in
  402. \fB/usr/share/git\-core/templates/\fR\&. You can use the
  403. \fBgitweb\&.description\fR
  404. repo configuration variable, but the file takes precedence\&.
  405. .RE
  406. .PP
  407. category (or \fBgitweb\&.category\fR)
  408. .RS 4
  409. Single line category of a project, used to group projects if
  410. \fB$projects_list_group_categories\fR
  411. is enabled\&. By default (file and configuration variable absent), uncategorized projects are put in the
  412. \fB$project_list_default_category\fR
  413. category\&. You can use the
  414. \fBgitweb\&.category\fR
  415. repo configuration variable, but the file takes precedence\&.
  416. .sp
  417. The configuration variables
  418. \fB$projects_list_group_categories\fR
  419. and
  420. \fB$project_list_default_category\fR
  421. are described in
  422. \fBgitweb.conf\fR(5)
  423. .RE
  424. .PP
  425. cloneurl (or multiple\-valued \fBgitweb\&.url\fR)
  426. .RS 4
  427. File with repository URL (used for clone and fetch), one per line\&. Displayed in the project summary page\&. You can use multiple\-valued
  428. \fBgitweb\&.url\fR
  429. repository configuration variable for that, but the file takes precedence\&.
  430. .sp
  431. This is per\-repository enhancement / version of global prefix\-based
  432. \fB@git_base_url_list\fR
  433. gitweb configuration variable (see
  434. \fBgitweb.conf\fR(5))\&.
  435. .RE
  436. .PP
  437. gitweb\&.owner
  438. .RS 4
  439. You can use the
  440. \fBgitweb\&.owner\fR
  441. repository configuration variable to set repository\(cqs owner\&. It is displayed in the project list and summary page\&.
  442. .sp
  443. If it\(cqs not set, filesystem directory\(cqs owner is used (via GECOS field, i\&.e\&. real name field from
  444. \fBgetpwuid\fR(3)) if
  445. \fB$projects_list\fR
  446. is unset (gitweb scans
  447. \fB$projectroot\fR
  448. for repositories); if
  449. \fB$projects_list\fR
  450. points to file with list of repositories, then project owner defaults to value from this file for given repository\&.
  451. .RE
  452. .PP
  453. various \fBgitweb\&.\fR* config variables (in config)
  454. .RS 4
  455. Read description of %feature hash for detailed list, and descriptions\&. See also "Configuring gitweb features" section in
  456. \fBgitweb.conf\fR(5)
  457. .RE
  458. .SH "ACTIONS, AND URLS"
  459. .sp
  460. Gitweb 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:
  461. .sp
  462. .if n \{\
  463. .RS 4
  464. .\}
  465. .nf
  466. \&.\&.\&./gitweb\&.cgi/<repo>/<action>/<revision>:/<path>?<arguments>
  467. .fi
  468. .if n \{\
  469. .RE
  470. .\}
  471. .PP
  472. repo
  473. .RS 4
  474. The repository the action will be performed on\&.
  475. .sp
  476. All actions except for those that list all available projects, in whatever form, require this parameter\&.
  477. .RE
  478. .PP
  479. action
  480. .RS 4
  481. The action that will be run\&. Defaults to
  482. \fIprojects_list\fR
  483. if repo is not set, and to
  484. \fIsummary\fR
  485. otherwise\&.
  486. .RE
  487. .PP
  488. revision
  489. .RS 4
  490. Revision shown\&. Defaults to HEAD\&.
  491. .RE
  492. .PP
  493. path
  494. .RS 4
  495. The path within the <repository> that the action is performed on, for those actions that require it\&.
  496. .RE
  497. .PP
  498. arguments
  499. .RS 4
  500. Any arguments that control the behaviour of the action\&.
  501. .RE
  502. .sp
  503. 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:
  504. .sp
  505. .if n \{\
  506. .RS 4
  507. .\}
  508. .nf
  509. \&.\&.\&./gitweb\&.cgi/<repo>/<action>/<revision\-from>:/<path\-from>\&.\&.<revision\-to>:/<path\-to>?<arguments>
  510. .fi
  511. .if n \{\
  512. .RE
  513. .\}
  514. .sp
  515. 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 \fIblame\fR view add the following to gitweb configuration file:
  516. .sp
  517. .if n \{\
  518. .RS 4
  519. .\}
  520. .nf
  521. $feature{\*(Aqblame\*(Aq}{\*(Aqdefault\*(Aq} = [1];
  522. .fi
  523. .if n \{\
  524. .RE
  525. .\}
  526. .SS "Actions:"
  527. .sp
  528. The standard actions are:
  529. .PP
  530. project_list
  531. .RS 4
  532. Lists the available Git repositories\&. This is the default command if no repository is specified in the URL\&.
  533. .RE
  534. .PP
  535. summary
  536. .RS 4
  537. Displays summary about given repository\&. This is the default command if no action is specified in URL, and only repository is specified\&.
  538. .RE
  539. .PP
  540. heads, remotes
  541. .RS 4
  542. Lists all local or all remote\-tracking branches in given repository\&.
  543. .sp
  544. The latter is not available by default, unless configured\&.
  545. .RE
  546. .PP
  547. tags
  548. .RS 4
  549. List all tags (lightweight and annotated) in given repository\&.
  550. .RE
  551. .PP
  552. blob, tree
  553. .RS 4
  554. Shows the files and directories in a given repository path, at given revision\&. This is default command if no action is specified in the URL, and path is given\&.
  555. .RE
  556. .PP
  557. blob_plain
  558. .RS 4
  559. Returns the raw data for the file in given repository, at given path and revision\&. Links to this action are marked
  560. \fIraw\fR\&.
  561. .RE
  562. .PP
  563. blobdiff
  564. .RS 4
  565. Shows the difference between two revisions of the same file\&.
  566. .RE
  567. .PP
  568. blame, blame_incremental
  569. .RS 4
  570. Shows the blame (also called annotation) information for a file\&. On a per line basis it shows the revision in which that line was last changed and the user that committed the change\&. The incremental version (which if configured is used automatically when JavaScript is enabled) uses Ajax to incrementally add blame info to the contents of given file\&.
  571. .sp
  572. This action is disabled by default for performance reasons\&.
  573. .RE
  574. .PP
  575. commit, commitdiff
  576. .RS 4
  577. Shows information about a specific commit in a repository\&. The
  578. \fIcommit\fR
  579. view shows information about commit in more detail, the
  580. \fIcommitdiff\fR
  581. action shows changeset for given commit\&.
  582. .RE
  583. .PP
  584. patch
  585. .RS 4
  586. Returns the commit in plain text mail format, suitable for applying with
  587. \fBgit-am\fR(1)\&.
  588. .RE
  589. .PP
  590. tag
  591. .RS 4
  592. Display specific annotated tag (tag object)\&.
  593. .RE
  594. .PP
  595. log, shortlog
  596. .RS 4
  597. Shows log information (commit message or just commit subject) for a given branch (starting from given revision)\&.
  598. .sp
  599. The
  600. \fIshortlog\fR
  601. view is more compact; it shows one commit per line\&.
  602. .RE
  603. .PP
  604. history
  605. .RS 4
  606. Shows history of the file or directory in a given repository path, starting from given revision (defaults to HEAD, i\&.e\&. default branch)\&.
  607. .sp
  608. This view is similar to
  609. \fIshortlog\fR
  610. view\&.
  611. .RE
  612. .PP
  613. rss, atom
  614. .RS 4
  615. Generates an RSS (or Atom) feed of changes to repository\&.
  616. .RE
  617. .SH "WEBSERVER CONFIGURATION"
  618. .sp
  619. This section explains how to configure some common webservers to run gitweb\&. In all cases, \fB/path/to/gitweb\fR in the examples is the directory you ran installed gitweb in, and contains \fBgitweb_config\&.perl\fR\&.
  620. .sp
  621. If you\(cqve configured a web server that isn\(cqt listed here for gitweb, please send in the instructions so they can be included in a future release\&.
  622. .SS "Apache as CGI"
  623. .sp
  624. Apache must be configured to support CGI scripts in the directory in which gitweb is installed\&. Let\(cqs assume that it is \fB/var/www/cgi\-bin\fR directory\&.
  625. .sp
  626. .if n \{\
  627. .RS 4
  628. .\}
  629. .nf
  630. ScriptAlias /cgi\-bin/ "/var/www/cgi\-bin/"
  631. <Directory "/var/www/cgi\-bin">
  632. Options Indexes FollowSymlinks ExecCGI
  633. AllowOverride None
  634. Order allow,deny
  635. Allow from all
  636. </Directory>
  637. .fi
  638. .if n \{\
  639. .RE
  640. .\}
  641. .sp
  642. With that configuration the full path to browse repositories would be:
  643. .sp
  644. .if n \{\
  645. .RS 4
  646. .\}
  647. .nf
  648. http://server/cgi\-bin/gitweb\&.cgi
  649. .fi
  650. .if n \{\
  651. .RE
  652. .\}
  653. .SS "Apache with mod_perl, via ModPerl::Registry"
  654. .sp
  655. You 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\&.
  656. .sp
  657. Assuming that gitweb is installed to \fB/var/www/perl\fR, the following Apache configuration (for mod_perl 2\&.x) is suitable\&.
  658. .sp
  659. .if n \{\
  660. .RS 4
  661. .\}
  662. .nf
  663. Alias /perl "/var/www/perl"
  664. <Directory "/var/www/perl">
  665. SetHandler perl\-script
  666. PerlResponseHandler ModPerl::Registry
  667. PerlOptions +ParseHeaders
  668. Options Indexes FollowSymlinks +ExecCGI
  669. AllowOverride None
  670. Order allow,deny
  671. Allow from all
  672. </Directory>
  673. .fi
  674. .if n \{\
  675. .RE
  676. .\}
  677. .sp
  678. With that configuration the full path to browse repositories would be:
  679. .sp
  680. .if n \{\
  681. .RS 4
  682. .\}
  683. .nf
  684. http://server/perl/gitweb\&.cgi
  685. .fi
  686. .if n \{\
  687. .RE
  688. .\}
  689. .SS "Apache with FastCGI"
  690. .sp
  691. Gitweb works with Apache and FastCGI\&. First you need to rename, copy or symlink gitweb\&.cgi to gitweb\&.fcgi\&. Let\(cqs assume that gitweb is installed in \fB/usr/share/gitweb\fR directory\&. The following Apache configuration is suitable (UNTESTED!)
  692. .sp
  693. .if n \{\
  694. .RS 4
  695. .\}
  696. .nf
  697. FastCgiServer /usr/share/gitweb/gitweb\&.cgi
  698. ScriptAlias /gitweb /usr/share/gitweb/gitweb\&.cgi
  699. Alias /gitweb/static /usr/share/gitweb/static
  700. <Directory /usr/share/gitweb/static>
  701. SetHandler default\-handler
  702. </Directory>
  703. .fi
  704. .if n \{\
  705. .RE
  706. .\}
  707. .sp
  708. With that configuration the full path to browse repositories would be:
  709. .sp
  710. .if n \{\
  711. .RS 4
  712. .\}
  713. .nf
  714. http://server/gitweb
  715. .fi
  716. .if n \{\
  717. .RE
  718. .\}
  719. .SH "ADVANCED WEB SERVER SETUP"
  720. .sp
  721. All of those examples use request rewriting, and need \fBmod_rewrite\fR (or equivalent; examples below are written for Apache)\&.
  722. .SS "Single URL for gitweb and for fetching"
  723. .sp
  724. If you want to have one URL for both gitweb and your \fBhttp://\fR repositories, you can configure Apache like this:
  725. .sp
  726. .if n \{\
  727. .RS 4
  728. .\}
  729. .nf
  730. <VirtualHost *:80>
  731. ServerName git\&.example\&.org
  732. DocumentRoot /pub/git
  733. SetEnv GITWEB_CONFIG /etc/gitweb\&.conf
  734. # turning on mod rewrite
  735. RewriteEngine on
  736. # make the front page an internal rewrite to the gitweb script
  737. RewriteRule ^/$ /cgi\-bin/gitweb\&.cgi
  738. # make access for "dumb clients" work
  739. RewriteRule ^/(\&.*\e\&.git/(?!/?(HEAD|info|objects|refs))\&.*)?$ \e
  740. /cgi\-bin/gitweb\&.cgi%{REQUEST_URI} [L,PT]
  741. </VirtualHost>
  742. .fi
  743. .if n \{\
  744. .RE
  745. .\}
  746. .sp
  747. The above configuration expects your public repositories to live under \fB/pub/git\fR and will serve them as \fBhttp://git\&.domain\&.org/dir\-under\-pub\-git\fR, both as clonable Git URL and as browsable gitweb interface\&. If you then start your \fBgit-daemon\fR(1) with \fB\-\-base\-path=/pub/git\fR \fB\-\-export\-all\fR then you can even use the \fBgit://\fR URL with exactly the same path\&.
  748. .sp
  749. Setting the environment variable \fBGITWEB_CONFIG\fR will tell gitweb to use the named file (i\&.e\&. in this example \fB/etc/gitweb\&.conf\fR) as a configuration for gitweb\&. You don\(cqt really need it in above example; it is required only if your configuration file is in different place than built\-in (during compiling gitweb) \fIgitweb_config\&.perl\fR or \fB/etc/gitweb\&.conf\fR\&. See \fBgitweb.conf\fR(5) for details, especially information about precedence rules\&.
  750. .sp
  751. If you use the rewrite rules from the example you \fBmight\fR also need something like the following in your gitweb configuration file (\fB/etc/gitweb\&.conf\fR following example):
  752. .sp
  753. .if n \{\
  754. .RS 4
  755. .\}
  756. .nf
  757. @stylesheets = ("/some/absolute/path/gitweb\&.css");
  758. $my_uri = "/";
  759. $home_link = "/";
  760. $per_request_config = 1;
  761. .fi
  762. .if n \{\
  763. .RE
  764. .\}
  765. .sp
  766. Nowadays though gitweb should create HTML base tag when needed (to set base URI for relative links), so it should work automatically\&.
  767. .SS "Webserver configuration with multiple projects\*(Aq root"
  768. .sp
  769. If you want to use gitweb with several project roots you can edit your Apache virtual host and gitweb configuration files in the following way\&.
  770. .sp
  771. The virtual host configuration (in Apache configuration file) should look like this:
  772. .sp
  773. .if n \{\
  774. .RS 4
  775. .\}
  776. .nf
  777. <VirtualHost *:80>
  778. ServerName git\&.example\&.org
  779. DocumentRoot /pub/git
  780. SetEnv GITWEB_CONFIG /etc/gitweb\&.conf
  781. # turning on mod rewrite
  782. RewriteEngine on
  783. # make the front page an internal rewrite to the gitweb script
  784. RewriteRule ^/$ /cgi\-bin/gitweb\&.cgi [QSA,L,PT]
  785. # look for a public_git directory in unix users\*(Aq home
  786. # http://git\&.example\&.org/~<user>/
  787. RewriteRule ^/\e~([^\e/]+)(/|/gitweb\&.cgi)?$ /cgi\-bin/gitweb\&.cgi \e
  788. [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
  789. # http://git\&.example\&.org/+<user>/
  790. #RewriteRule ^/\e+([^\e/]+)(/|/gitweb\&.cgi)?$ /cgi\-bin/gitweb\&.cgi \e
  791. [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
  792. # http://git\&.example\&.org/user/<user>/
  793. #RewriteRule ^/user/([^\e/]+)/(gitweb\&.cgi)?$ /cgi\-bin/gitweb\&.cgi \e
  794. [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
  795. # defined list of project roots
  796. RewriteRule ^/scm(/|/gitweb\&.cgi)?$ /cgi\-bin/gitweb\&.cgi \e
  797. [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT]
  798. RewriteRule ^/var(/|/gitweb\&.cgi)?$ /cgi\-bin/gitweb\&.cgi \e
  799. [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT]
  800. # make access for "dumb clients" work
  801. RewriteRule ^/(\&.*\e\&.git/(?!/?(HEAD|info|objects|refs))\&.*)?$ \e
  802. /cgi\-bin/gitweb\&.cgi%{REQUEST_URI} [L,PT]
  803. </VirtualHost>
  804. .fi
  805. .if n \{\
  806. .RE
  807. .\}
  808. .sp
  809. Here actual project root is passed to gitweb via \fBGITWEB_PROJECT_ROOT\fR environment variable from a web server, so you need to put the following line in gitweb configuration file (\fB/etc/gitweb\&.conf\fR in above example):
  810. .sp
  811. .if n \{\
  812. .RS 4
  813. .\}
  814. .nf
  815. $projectroot = $ENV{\*(AqGITWEB_PROJECTROOT\*(Aq} || "/pub/git";
  816. .fi
  817. .if n \{\
  818. .RE
  819. .\}
  820. .sp
  821. \fBNote\fR that this requires to be set for each request, so either \fB$per_request_config\fR must be false, or the above must be put in code referenced by \fB$per_request_config\fR;
  822. .sp
  823. These configurations enable two things\&. First, each unix user (\fI<user>\fR) of the server will be able to browse through gitweb Git repositories found in \fB~/public_git/\fR with the following url:
  824. .sp
  825. .if n \{\
  826. .RS 4
  827. .\}
  828. .nf
  829. http://git\&.example\&.org/~<user>/
  830. .fi
  831. .if n \{\
  832. .RE
  833. .\}
  834. .sp
  835. If you do not want this feature on your server just remove the second rewrite rule\&.
  836. .sp
  837. If you already use \fBmod_userdir\fR in your virtual host or you don\(cqt want to use the \*(Aq~\*(Aq as first character, just comment or remove the second rewrite rule, and uncomment one of the following according to what you want\&.
  838. .sp
  839. Second, repositories found in \fB/pub/scm/\fR and \fB/var/git/\fR will be accessible through \fBhttp://git\&.example\&.org/scm/\fR and \fBhttp://git\&.example\&.org/var/\fR\&. You can add as many project roots as you want by adding rewrite rules like the third and the fourth\&.
  840. .SS "PATH_INFO usage"
  841. .sp
  842. If you enable PATH_INFO usage in gitweb by putting
  843. .sp
  844. .if n \{\
  845. .RS 4
  846. .\}
  847. .nf
  848. $feature{\*(Aqpathinfo\*(Aq}{\*(Aqdefault\*(Aq} = [1];
  849. .fi
  850. .if n \{\
  851. .RE
  852. .\}
  853. .sp
  854. in your gitweb configuration file, it is possible to set up your server so that it consumes and produces URLs in the form
  855. .sp
  856. .if n \{\
  857. .RS 4
  858. .\}
  859. .nf
  860. http://git\&.example\&.com/project\&.git/shortlog/sometag
  861. .fi
  862. .if n \{\
  863. .RE
  864. .\}
  865. .sp
  866. i\&.e\&. without \fIgitweb\&.cgi\fR part, by using a configuration such as the following\&. This configuration assumes that \fB/var/www/gitweb\fR is the DocumentRoot of your webserver, contains the gitweb\&.cgi script and complementary static files (stylesheet, favicon, JavaScript):
  867. .sp
  868. .if n \{\
  869. .RS 4
  870. .\}
  871. .nf
  872. <VirtualHost *:80>
  873. ServerAlias git\&.example\&.com
  874. DocumentRoot /var/www/gitweb
  875. <Directory /var/www/gitweb>
  876. Options ExecCGI
  877. AddHandler cgi\-script cgi
  878. DirectoryIndex gitweb\&.cgi
  879. RewriteEngine On
  880. RewriteCond %{REQUEST_FILENAME} !\-f
  881. RewriteCond %{REQUEST_FILENAME} !\-d
  882. RewriteRule ^\&.* /gitweb\&.cgi/$0 [L,PT]
  883. </Directory>
  884. </VirtualHost>
  885. .fi
  886. .if n \{\
  887. .RE
  888. .\}
  889. .sp
  890. 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\&.
  891. .sp
  892. \fBNotice\fR that in this case you don\(cqt need special settings for \fB@stylesheets\fR, \fB$my_uri\fR and \fB$home_link\fR, but you lose "dumb client" access to your project \&.git dirs (described in "Single URL for gitweb and for fetching" section)\&. A possible workaround for the latter is the following: in your project root dir (e\&.g\&. \fB/pub/git\fR) have the projects named \fBwithout\fR a \&.git extension (e\&.g\&. \fB/pub/git/project\fR instead of \fB/pub/git/project\&.git\fR) and configure Apache as follows:
  893. .sp
  894. .if n \{\
  895. .RS 4
  896. .\}
  897. .nf
  898. <VirtualHost *:80>
  899. ServerAlias git\&.example\&.com
  900. DocumentRoot /var/www/gitweb
  901. AliasMatch ^(/\&.*?)(\e\&.git)(/\&.*)?$ /pub/git$1$3
  902. <Directory /var/www/gitweb>
  903. Options ExecCGI
  904. AddHandler cgi\-script cgi
  905. DirectoryIndex gitweb\&.cgi
  906. RewriteEngine On
  907. RewriteCond %{REQUEST_FILENAME} !\-f
  908. RewriteCond %{REQUEST_FILENAME} !\-d
  909. RewriteRule ^\&.* /gitweb\&.cgi/$0 [L,PT]
  910. </Directory>
  911. </VirtualHost>
  912. .fi
  913. .if n \{\
  914. .RE
  915. .\}
  916. .sp
  917. The additional AliasMatch makes it so that
  918. .sp
  919. .if n \{\
  920. .RS 4
  921. .\}
  922. .nf
  923. http://git\&.example\&.com/project\&.git
  924. .fi
  925. .if n \{\
  926. .RE
  927. .\}
  928. .sp
  929. will give raw access to the project\(cqs Git dir (so that the project can be cloned), while
  930. .sp
  931. .if n \{\
  932. .RS 4
  933. .\}
  934. .nf
  935. http://git\&.example\&.com/project
  936. .fi
  937. .if n \{\
  938. .RE
  939. .\}
  940. .sp
  941. will provide human\-friendly gitweb access\&.
  942. .sp
  943. This solution is not 100% bulletproof, in the sense that if some project has a named ref (branch, tag) starting with \fBgit/\fR, then paths such as
  944. .sp
  945. .if n \{\
  946. .RS 4
  947. .\}
  948. .nf
  949. http://git\&.example\&.com/project/command/abranch\&.\&.git/abranch
  950. .fi
  951. .if n \{\
  952. .RE
  953. .\}
  954. .sp
  955. will fail with a 404 error\&.
  956. .SH "BUGS"
  957. .sp
  958. Please report any bugs or feature requests to \m[blue]\fBgit@vger\&.kernel\&.org\fR\m[]\&\s-2\u[1]\d\s+2, putting "gitweb" in the subject of email\&.
  959. .SH "SEE ALSO"
  960. .sp
  961. \fBgitweb.conf\fR(5), \fBgit-instaweb\fR(1)
  962. .sp
  963. \fBgitweb/README\fR, \fBgitweb/INSTALL\fR
  964. .SH "GIT"
  965. .sp
  966. Part of the \fBgit\fR(1) suite
  967. .SH "NOTES"
  968. .IP " 1." 4
  969. git@vger.kernel.org
  970. .RS 4
  971. \%mailto:git@vger.kernel.org
  972. .RE