10

My question

I'm trying to share a git repo on our company intranet server using the dumb http protocol, which should only require file access, but it fails with

fatal: repository 'http://my-url/repo.git' not found

But pasting the same link in Firefox gives me the index to the bare repo with branches/, config, description, HEAD etc. All directories and files are readable. In fact, if I download the whole thing recursively with wget I could git clone locally from that, so all required files seems accessible without issues.

$ wget -r --no-parent --reject "index.html*" http://my-url/repo.git
$ git clone repo.git test
Cloning into 'test'...
done.

Continuing the debugging I tried verbose output with GIT_CURL_VERBOSE and GIT_TRACE:

$ GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone http://my-url/repo.git test
trace: built-in: git 'clone' 'http://my-url/repo.git' 'test'
Cloning into 'test'...
trace: run_command: 'git-remote-http' 'origin' 'http://my-url/repo.git'
* Couldn't find host my-url in the .netrc file; using defaults
* About to connect() to my-url port 80 (#0)
*   Trying <ip>...
* Connected to my-url (<ip>) port 80 (#0)
> GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.3.1
Host: my-url
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

< HTTP/1.1 404 Not Found
< Date: Fri, 04 Sep 2015 13:41:56 GMT
< Server: Apache/2.2.15 (Red hat)
< shortcut-icon: /images/logo.ico
< Content-Length: 346
< Content-Type: text/html; charset=iso-8859-1
< X-Cache: MISS from my-url
< 
* Connection #0 to host my-url left intact
fatal: repository 'http://my-host/repo.git/' not found

And to me it looks like it gives up after trying the "smart" http protocol. So, what's going on? From what I've been able to gather the dumb http protocol hasn't been dropped. Why does git give up after trying the smart http?

Details

  • HTTP Server is Apache 2.2.15
  • Anonymous read access via HTTP is allowed
  • git version 1.8.3.1
  • The repo is bare and is not symlinked
  • git update-server-info has manually been called.
  • I don't have access to the server and can't configure it, so the "smart http" option is out.
  • The only thing in any (global, system, local) git-config is user.name and user.email.
  • env | grep GIT is empty
  • The results are the same for https.

Edit: Updated with results for https (same)


Similar questions

Similar question but without answers that are helpful in this case: Git Clone - Repository not found

Also similar, but the accepted answer uses "smart http" protocol. git clone over HTTP Fails with “repository not found”

mandrake
  • 1,213
  • 1
  • 14
  • 28
  • 1
    Can you verify that you have the files `info/refs` and `objects/info/packs` in the remote repo (i.e. trough Firefox) – joran Sep 04 '15 at 15:08
  • I can check on Monday (I left for the weekend). But `git` doesn't even try to download those files, as shown by `GIT_CURL_VERBOSE`? – mandrake Sep 04 '15 at 16:03
  • Yes, `info/refs` and `objects/info/packs` are there. – mandrake Sep 07 '15 at 06:35

2 Answers2

8

It seems you have to run:

git update-server-info

Before the repo can be served via http.

You also need to switch on the post-update hook:

mv hooks/post-update.sample hooks/post-update

This re-runs git update-server-info whenever new changes are pushed to the repo.

See the section on "Dumb http" here for more info:

https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols

John Gill
  • 181
  • 2
  • 6
  • The the environment variable answer didn't apply to me for git client version `2.11.1`. This answer solved my cloning problem git server version `1.8.3.1` – Bryce Guinta Aug 08 '17 at 23:10
7

TL;DR: Manually provide option to disable "smart" http protocol:

$ GIT_SMART_HTTP=0 git clone http://my-dumb-http-server/repo.git

But according to https://git-scm.com/book/ch4-1.html:

If the server does not respond with a Git HTTP smart service, the Git client will try to fall back to the simpler “dumb” HTTP protocol.

This does not seem to be the case for some reason. But after digging around in the code I saw that they check for GIT_SMART_HTTP environment variable and I got git clone working by setting GIT_SMART_HTTP=0.

mandrake
  • 1,213
  • 1
  • 14
  • 28
  • Having the same issue I've found some context (i.e. why it works that way) http://permalink.gmane.org/gmane.comp.version-control.git/206096 – The user with no hat Apr 19 '16 at 20:35
  • @Theuserwithnohat The link leads to a "Not Found" page. Do you remember the subject, so it can be found again? – JayK Dec 01 '16 at 22:27