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
git update-server-info
has manually been called.user.name
and user.email
.env | grep GIT
is emptyhttps
.Edit: Updated with results for https (same)
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”
The SSH Protocol Probably the most common transport protocol for Git is SSH. This is because SSH access to servers is already set up in most places — and if it isn't, it's easy to do. SSH is also the only network-based protocol that you can easily read from and write to.
Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH) and Git.
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance.
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
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With