I've set up apache to use git-http-backend as per the instructions in the pro git book, and its manpage. My apache config now looks like:

SetEnv GIT_PROJECT_ROOT /var/www/git
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
Require group committers

I can clone a repo using git clone http: //user@url/git/repo.git
which prompts me for the password for 'user', then continues. However, when I attempt to push, I'm prompted for my password twice, and then get an error:

Cannot access URL http: //user@url/git/repo.git/, return code 22

(I've inserted a space into the URLs, because the spam prevention mechanism won't let me post otherwise)

When I look at my apache log, I see: - - [12/Sep/2010:20:11:22 +0100] "GET /git/repo.git/info/refs?service=git-receive-pack HTTP/1.1" 403 - "-" "git/" - - [12/Sep/2010:20:11:23 +0100] "GET /git/repo.git/info/refs HTTP/1.1" 200 59 "-" "git/" - - [12/Sep/2010:20:11:23 +0100] "GET /git/repo.git/HEAD HTTP/1.1" 200 23 "-" "git/" - - [12/Sep/2010:20:11:26 +0100] "PROPFIND /git/repo.git/ HTTP/1.1" 404 - "-" "git/"

I've added 'user' to the 'committers' group on the server (seemed easiest to just follow the instructions), and my local .netrc (chmodded 600) looks like this:

machine address
login user
password pass

Every instruction I've found seems slightly unclear as to whether I have to enable DAV for the dir in question (I thought that was the old way to do it, though). I could just use gitolite, but I'd like to get to the bottom of this first…


PROPFIND is a non-standard webdav HTTP method.
You'll need to enable webdav for the location of your repository. Enable mod_dav in httpd.conf and add this to your vhost LocationMatch block:

<LocationMatch "^/git/.*/git-receive-pack$">
  Dav on

Then make sure your Apache user has write access to your repository.


The important thing in your apache log is the following line: - - [12/Sep/2010:20:11:22 +0100] "GET /git/repo.git/info/refs?service=git-receive-pack HTTP/1.1" 403 - "-" "git/"

git-http-backend is returning a 403/Forbidden code when the client asks to use the git-receive-pack method. It then falls back to WebDAV, but using WebDAV is not necessary.

I had the same problem; in my case this was due to REMOTE_USER not being set. In my case, REDIRECT_REMOTE_USER /was/ set, so I set REMOTE_USER to REDIRECT_REMOTE_USER, which solved the problem.

I documented my setup on my blog - and see if that works for you.

  • @valhallasw Where did you add the REMOTE_USER part? – user87986 Jul 18 '11 at 12:12
  • In the CGI handler script - before calling git-http-backend, it sets REMOTE_USER=$REDIRECT_REMOTE_USER if $REMOTE_USER is not set. – valhallasw Aug 4 '12 at 22:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.