Create /etc/apache2/conf.d/git-http-backend with these contents:
# Setup git-http-backend to reside at the same URL as GitWeb SetEnv GIT_PROJECT_ROOT /var/cache/git/ SetEnv GIT_HTTP_EXPORT_ALL # otherwise, repos need to be individually enabled with git-daemon-export-ok ScriptAliasMatch \ "(?x)^/gitweb/(.*/(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 ScriptAliasMatch "^/gitweb/([^?].*\.git)$" \ /usr/share/gitweb/index.cgi/$1 ##### Require HTTP Basic Authentication for pushes (optional) ##### # Dang. This doesn't work as-is, despite being suggested by the git-http-backend manpage. # # see http://git.661346.n2.nabble.com/git-http-backend-and-Authenticated-Pushes-td4703506.html #<LocationMatch "^/gitweb/.*/git-receive-pack$"> # AuthType Basic # AuthName "Git Access" # AuthUserFile /var/cache/git/push.htpasswd # Require valid-user #</LocationMatch> RewriteCond %{QUERY_STRING} =service=git-receive-pack [OR] RewriteCond %{REQUEST_URI} /git-receive-pack$ RewriteRule (.*) $1 [E=AUTHREQUIRED:yes] <Location /gitweb/> Order Deny,Allow Deny from env=AUTHREQUIRED AuthType Basic AuthName "Git Access" AuthUserFile /var/cache/git/push.htpasswd Require valid-user Satisfy Any <Location> # use this URL to test the above: # # http://localhost/gitweb/git_test1.git/info/refs?service=git-receive-pack
Then run: /etc/init.d/apache2 reload
Now you should be able to use this URL to 1) view from a browser, or 2) git-clone or git-push it:
Service not enabled: 'receive-pack'This means that $REMOTE_USER isn't set — that is, user-authentication failed. Git-http-backend needs the $REMOTE_USER to be set in order to record who did the PUSH.