Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
Require group committers
</LocationMatch>

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:
192.168.1.151 - - [12/Sep/2010:20:11:22 +0100] "GET /git/repo.git/info/refs?service=git-receive-pack HTTP/1.1" 403 - "-" "git/1.7.2.3"
192.168.1.151 - - [12/Sep/2010:20:11:23 +0100] "GET /git/repo.git/info/refs HTTP/1.1" 200 59 "-" "git/1.7.2.3"
192.168.1.151 - - [12/Sep/2010:20:11:23 +0100] "GET /git/repo.git/HEAD HTTP/1.1" 200 23 "-" "git/1.7.2.3"
192.168.1.151 - - [12/Sep/2010:20:11:26 +0100] "PROPFIND /git/repo.git/ HTTP/1.1" 404 - "-" "git/1.7.2.3"

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…

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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
</LocationMatch>

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

share|improve this answer

The important thing in your apache log is the following line:

  192.168.1.151 - - [12/Sep/2010:20:11:22 +0100] "GET /git/repo.git/info/refs?service=git-receive-pack HTTP/1.1" 403 - "-" "git/1.7.2.3"

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.

share|improve this answer
    
@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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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