Tested on Debian10
With subversion we were used to have a server that provides checkout/checkin operations as well as repository browsing. This blog shows how this can be achieved with git/gitweb as well.
Prerequisites
The following packages have to be installed:
apache2, git, gitweb
The Idea
We need to have a switch point that sends fetch/pull requests to the repository backend but browsing requests to the gitweb frontend. Therefore the apache configuration file consist of the two parts.
Repository backend
This blog assumes no access control for reading the repository but controls the pull requests.
This leads to the following apache2 configuration:
SetEnv GIT_PROJECT_ROOT /path/to/repos SetEnv GIT_HTTP_EXPORT_ALL # Enable git clone over HTTP ScriptAliasMatch \ "(?x)^/git/(.*/(HEAD | \ info/refs | \ objects/(info/[^/]+ | \ [0-9a-f]{2}/[0-9a-f]{38} | \ pack/pack-[0-9a-f]{40}\.(pack|idx)) | \ git-(upload|receive)-pack))$" \ /usr/lib/git-core/git-http-backend/$1 # define access control <LocationMatch "^/git/"> AuthType Basic AuthName "Git Access" AuthUserFile /var/svn/dav_svn.passwd Require all granted <If "%{QUERY_STRING} == 'service=git-receive-pack' || %{REQUEST_URI} =~ m#/git/.*/git-receive-pack#" > Require valid-user </If> </LocationMatch>
Gitweb Frontend
Apache2 configuration:
# ScriptAlias for gitweb ScriptAlias /git /usr/share/gitweb/index.cgi Alias /static /usr/share/gitweb/static
In addition the gitweb configfile (/etc/gitweb.conf) has to be adjusted, al least the $projectroot.
Letzte Aktualisierung: 19.2.2021