Git clone:“您似乎克隆了一个空的存储库” [英] Git clone: "You appear to have cloned an empty repository"
问题描述
有些同事和我一直在研究存储在私人git存储库中的项目。从历史上看,没有问题,但最近我试图克隆,并得到以下问题:
克隆到'project' ...
警告:您似乎已经克隆了一个空的存储库。
检查连通性...完成。
A git log
提供:
fatal:您当前的分支'master'没有任何提交
这是不正确的 - 我的同事推12月6日发生了很多(非空)的更改(尽管现在该分支没有显示在单分支克隆尝试上)。当他进入git仓库时,有很多目录结构。
所以我的问题:
- 这怎么可能发生?
- 我们如何恢复存储库?它似乎是东西在远程回购,但由于某种原因,它不知道它在那里。
如果回购托管在gitlab服务器上,并且您使用
如果 giltab-git-http-server
没有正确配置,那么通过HTTP的Git将收到一个空的repo
如果由于某种原因
gitlab-git -http-server
配置不当,
或者您正在使用自定义nginx或Apache代理直接将
转发给Unicorn,并且您尝试通过HTTP进行克隆,请求成功,
您收到200和一个空的回购。
快速修复是使用 git over ssh 克隆回购站。
Some colleagues and I have been working on a project stored in a private git repository. Historically, there have been no problems, but recently I attempted to clone, and got the following problem:
Cloning into 'project'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
A git log
provides:
fatal: your current branch 'master' does not have any commits yet
This isn't correct - my colleague pushed plenty of (nonempty) changes on Dec. 6 (although now that branch isn't showing on a --single-branch clone attempt). When he ssh's into the git repository, there is plenty of directory structure there.
So my questions:
- How could this have happened?
- How can we recover the repository? It seems the stuff is on the remote repo, but for some reason, it isn't aware that it's there.
If the repo is hosted on a gitlab server, and you used git over http
to clone the repo, it could be related to this:
Git over HTTP will receive an empty repo if giltab-git-http-server
is not properly configured
If for some reason
gitlab-git-http-server
is not properly configured, or you are using a custom nginx or Apache proxy that forwards directly to Unicorn and you attempt to clone via HTTP, the request succeeds, you receive a 200 and an empty repo.
A quick fix is to use git over ssh to clone the repo.
这篇关于Git clone:“您似乎克隆了一个空的存储库”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!