Git - gitweb Documentation (2024)

All of those examples use request rewriting, and need mod_rewrite(or equivalent; examples below are written for Apache).

Single URL for gitweb and for fetching

If you want to have one URL for both gitweb and your http://repositories, you can configure Apache 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 # 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/pub/git and will serve them as http://git.domain.org/dir-under-pub-git,both as clonable Git URL and as browsable gitweb interface. If you thenstart your git-daemon[1] with --base-path=/pub/git --export-allthen you can even use the git:// URL with exactly the same path.

Setting the environment variable GITWEB_CONFIG will tell gitweb to use thenamed file (i.e. in this example /etc/gitweb.conf) as a configuration forgitweb. You don’t really need it in above example; it is required only ifyour configuration file is in different place than built-in (duringcompiling gitweb) gitweb_config.perl or /etc/gitweb.conf. Seegitweb.conf[5] for details, especially information about precedencerules.

If you use the rewrite rules from the example you might also needsomething like the following in your gitweb configuration file(/etc/gitweb.conf following example):

@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 baseURI for relative links), so it should work automatically.

Webserver configuration with multiple projects' root

If you want to use gitweb with several project roots you can edit yourApache virtual host and gitweb configuration files in the following way.

The virtual host configuration (in Apache configuration file) should looklike 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 GITWEB_PROJECT_ROOTenvironment variable from a web server, so you need to put the followingline in gitweb configuration file (/etc/gitweb.conf in above example):

$projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";

Note that this requires to be set for each request, so either$per_request_config must be false, or the above must be put in codereferenced by $per_request_config;

These configurations enable two things. First, each unix user (<user>) ofthe server will be able to browse through gitweb Git repositories found in~/public_git/ with the following url:

http://git.example.org/~<user>/

If you do not want this feature on your server just remove the secondrewrite rule.

If you already use mod_userdir in your virtual host or you don’t want touse the '~' as first character, just comment or remove the second rewriterule, and uncomment one of the following according to what you want.

Second, repositories found in /pub/scm/ and /var/git/ will be accessiblethrough http://git.example.org/scm/ and http://git.example.org/var/.You can add as many project roots as you want by adding rewrite rules likethe third and the fourth.

PATH_INFO usage

If 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 sothat 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 thefollowing. This configuration assumes that /var/www/gitweb is theDocumentRoot of your webserver, contains the gitweb.cgi script andcomplementary static files (stylesheet, favicon, JavaScript):

<VirtualHost *:80>ServerAlias git.example.comDocumentRoot /var/www/gitweb<Directory /var/www/gitweb>Options ExecCGIAddHandler cgi-script cgiDirectoryIndex gitweb.cgiRewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^.* /gitweb.cgi/$0 [L,PT]</Directory></VirtualHost>

The rewrite rule guarantees that existing static files will be properlyserved, whereas any other URL will be passed to gitweb as PATH_INFOparameter.

Notice that in this case you don’t need special settings for@stylesheets, $my_uri and $home_link, but you lose "dumb client"access to your project .git dirs (described in "Single URL for gitweb andfor fetching" section). A possible workaround for the latter is thefollowing: in your project root dir (e.g. /pub/git) have the projectsnamed without a .git extension (e.g. /pub/git/project instead of/pub/git/project.git) and configure Apache as follows:

<VirtualHost *:80>ServerAlias git.example.comDocumentRoot /var/www/gitwebAliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3<Directory /var/www/gitweb>Options ExecCGIAddHandler cgi-script cgiDirectoryIndex gitweb.cgiRewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^.* /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 becloned), 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 hasa named ref (branch, tag) starting with git/, then paths such as

http://git.example.com/project/command/abranch..git/abranch

will fail with a 404 error.

Git - gitweb Documentation (2024)

References

Top Articles
Recetas Con Almeja, Apio, Arroz Para Paella, Cebolla Roja, Cebolla Verde, Conejo, Harina Para Todo Uso, Hoja De Laurel, Pan, Panceta, Pasta Corta, Pasta De Ajo, Pechuga De Pollo, Perejil, Puerro, Pulpo, Setas Variadas, Tomillo, Vinagre, Vino Blanco & Zana
¿Qué restaurantes no debes perderte en Benidorm?
How To Check Your Rust Inventory Value? 🔫
Refinery29 Horoscopes
Moonrise Tonight Near Me
Buenasado Bluewater
Msc Open House Fall 2023
Food Universe Near Me Circular
LensCrafters Review for September 2024 | Best Contact Lens Stores
6 Underground movie review & film summary (2019) | Roger Ebert
8776685260
Craigslist Sf Furniture
888-490-1703
Madison.ellee
Maximise Your Funding: Key Insights on Accounting for Grants
Bowser's Fury Coloring Page
Ups Store Pineville La
Vanity Fair Muckrack
Hdmovie 2
Kagtwt
Walmart Careers Stocker
SuperLotto Plus | California State Lottery
FirstLight Power to Acquire Leading Canadian Renewable Operator and Developer Hydromega Services Inc. - FirstLight
1773X To
3 Hour Radius From Me
Proctor Funeral Home Obituaries Beaumont Texas
Ogłoszenia - Sprzedam, kupię na OLX.pl
Shannon Ray Booty
Dicks Sporting Good Lincoln Ne
Meet The Parents Putlocker
Credit Bureau Contact Information
Horseheads Schooltool
Charm City Kings 123Movies
Lenscrafters Westchester Mall
Aeorian Security Cannon
Sydney V May Of Leaked
Retro Bowl Unblocked Game 911: A Complete Guide - Unigamesity
My Perspectives Grade 10 Volume 1 Answer Key Pdf
Bank Of America Financial Center Irvington Photos
Nsfw Otp Prompt Generator Dyslexic Friendly
Mathlanguage Artsrecommendationsskill Plansawards
Chuck Wagon Café, le restaurant de l'hôtel Cheyenne à Disneyland Paris : prix et infos
ExtraCare Rewards at the Pharmacy – Target | CVS
20|21 Art: The Chicago Edition 2023-01-25 Auction - 146 Price Results - Wright in IL
Is The Rubber Ducks Game Cancelled Today
Kingsport Weather Channel
Csgo Xray Command
Mpbn Schedule
Jami Lafay Gofundme
Kaiju Universe: Best Monster Tier List (January 2024) - Item Level Gaming
Omgekeerd zoeken op telefoonnummer | Telefoonboek.nl
Richy Rich Dispensary
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 6451

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.