1

I have a git repository hosted on a personal, Debian based, Apache web server. If I access it like:
git "command" user@server:/path/to/repo.git
I can clone, push, pull, etc. no problem. Next, I added a virtual host and added a sub-domain to my DNS record so git.domain.com went to the directory in which I will be storing my repositories in. I can successfully navigate to git.domain.com/repo.git and see the files and directories in the repository. But, when I try to clone it through http with the domain:
git clone git.domain.com/repo.git
it results in the error:
warning: You appear to have cloned an empty repository.
I am really thrown by this error because I can clone it with ssh, and interally on the server (git clone /path/to/repo) and the web server should be serving the files exactly how they are internally.

After I cloned it and I recieved an empty repository, I went into the repository directory and ran git show-ref and the command went through (without failure) but had no output.

Any help would be appreciated. Thank you!

Spencer Bravo
  • 31
  • 1
  • 7
  • 2
    Can you try running `git update-server-info` (on the server site), this is needed in case you are using the "dumb" git HTTP protocol, git uses this protocol if you are just accessing a directory, without using the GIT CGI script, see [10.6 Git Internals - Transfer Protocols](https://git-scm.com/book/uz/v2/Git-Internals-Transfer-Protocols) – Ferrybig Aug 15 '17 at 07:49
  • Thank you! Fixed out problem. – Spencer Bravo Aug 15 '17 at 20:11

1 Answers1

0

When exposing your repository from the so called "Dumb http backend" (a web server serving a git directory), it is required to keep certain files up to date. By default, git does not keep these files up to date, since that would mean that it is using unneeded CPU cycles for something only a tiny part of all git users use.

You can directly update these files using git update-server-info, but care should be taken to do this after every change to the repo to keep the files up to date.

Making sure this file stays up to date, is by configuring git to automatically run the above named command when a push comes using another transport. This can be easily enabled by going to .git/hook, and renaming post-update.sample to post-update.

Notice that running git over http this way can create a high server load because it usually needs to request many files from the server, and it isn't smart enough to download pack files partially if the client already has some parts of the file. This behaviour can be improved by using the Smart git HTTP backend, as explained by https://git-scm.com/book/en/v2/Git-on-the-Server-Smart-HTTP

Ferrybig
  • 18,194
  • 6
  • 57
  • 79