简体   繁体   中英

Cloning git repository over HTTP on personal server results in cloning an empty repository

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM