Git push over http (using git-http-backend) and Apache is not working
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
Related videos on Youtube
Nils Magne Lunde
Architect/developer that are mostly working with C# and JavaScript these days.
Updated on September 18, 2022Comments
-
Nils Magne Lunde over 1 year
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 toroot.www-data
and for my test repositories I have enabled anonymous push by doinggit 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.
-
Rishi Kulshreshtha over 8 yearsI'm facing the exact same issue, did you got any solution?
-
Nils Magne Lunde over 8 years@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.
-
Nils Magne Lunde over 8 yearsOk, tried Deepika's solution, but no success.
-
-
Nils Magne Lunde almost 12 yearsHi. I started out using the ScriptAlias directive, but it didn't work.
-
theV0ID over 9 yearsSame problem here. Have you found a solution?
-
Nils Magne Lunde over 9 years@theV0ID No, I never found a solution. Using GitHub now instead of a local Git server.