11

I have desperately been trying to get push for git working through the "smart-http" mode using git-http-backend. However after many hours of testing and troubleshooting, I am still left with

error: Cannot access URL http://localhost/git/hello.git/, return code 22
fatal: git-http-push failed`

I am using latest versions of Ubuntu (12.04), Apache2 (2.2.22) and Git (1.7.9.5) and have followed different tutorials found on the Internet, like this one http://www.parallelsymmetry.com/howto/git.jsp.

My VHost file currently looks like this:

<VirtualHost *:80>

    SetEnv GIT_PROJECT_ROOT /var/www/git
    SetEnv GIT_HTTP_EXPORT_ALL
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

    DocumentRoot /var/www/git

    ScriptAliasMatch \
            "(?x)^/(.*?)\.git/(HEAD | \
                                            info/refs | \
                                            objects/info/[^/]+ | \
                                            git-(upload|receive)-pack)$" \
            /usr/lib/git-core/git-http-backend/$1/$2

    <Directory /var/www/git>
            Options +ExecCGI +SymLinksIfOwnerMatch -MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

</VirtualHost>

I have changed the ownership of the /var/www/git folder to root.www-data and for my test repositories I have enabled anonymous push by doing git config http.receivepack true. I have also tried with authenticated users but with the same outcome.

The repositories were created using: sudo git init --bare --shared [repo-name]

While looking at the apache2 access.log, it appears to me that WebDAV is trying to be used, and that git-http-backend is never fired:

127.0.0.1 - - [20/May/2012:23:04:53 +0200] "GET /git/hello.git/info/refs?service=git-receive-pack HTTP/1.1" 200 207 "-" "git/1.7.9.5"
127.0.0.1 - - [20/May/2012:23:04:53 +0200] "GET /git/hello.git/HEAD HTTP/1.1" 200 232 "-" "git/1.7.9.5"
127.0.0.1 - - [20/May/2012:23:04:53 +0200] "PROPFIND /git/hello.git/ HTTP/1.1" 405 563 "-" "git/1.7.9.5"

What am I doing wrong? Is it an issue with the version of git and/or apache that I am using perhaps?

BTW: I have read all the git http related questions on ServerFault and StackOverflow, and none of them provided me with a solution, so please don't mark this as duplicate.

4
  • I'm facing the exact same issue, did you got any solution? Dec 28, 2015 at 11:46
  • @RishiKulshreshtha: Sorry, did not find any solution. Moved on to GitHub instead... That said I have not tried the solution from Deepika. If someone can verify that it works I will accept that answer. Dec 28, 2015 at 12:31
  • Ok, tried Deepika's solution, but no success. Dec 28, 2015 at 13:25
  • Even I tried Deepika's solution just now, that didn't worked for me as well. Dec 28, 2015 at 13:58

2 Answers 2

1

I think the fact that WebDAV is getting used means that your CGI stuff is not configured properly.

Try to use the ScriptAlias directive the way they show it in the tutorial you said you were following.

ScriptAlias /git /usr/lib/git-core/git-http-backend
3
  • Hi. I started out using the ScriptAlias directive, but it didn't work. May 21, 2012 at 6:06
  • Same problem here. Have you found a solution?
    – kostrykin
    Nov 4, 2014 at 13:30
  • @theV0ID No, I never found a solution. Using GitHub now instead of a local Git server. Nov 5, 2014 at 8:19
0

To Fix this we need to enable WebDav at apache server using 2 steps

  1. enable at vhost file of apache

SetEnv GIT_PROJECT_ROOT /var/www/git
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

DocumentRoot /var/www/git

<Directory /var/www/git>
        Options +ExecCGI +SymLinksIfOwnerMatch -MultiViews

        AllowOverride None
        Order allow,deny
        allow from all
        Dav On
</Directory>

  1. Run this command at command prompt

    a2enmod dav_fs

  2. Then restart apache server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .