Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git clone: "You appear to have cloned an empty repository"

Tags:

git

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:

  1. How could this have happened?
  2. 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.
like image 929
user650261 Avatar asked Dec 19 '15 19:12

user650261


2 Answers

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.

like image 109
Emile Bergeron Avatar answered Oct 12 '22 23:10

Emile Bergeron


You have cloned the correct repository. I think they have not pushed into the master branch. The other branches will be there like origin/development-example. You need to make a local branch which can track the remote branches and then you can get the latest code. This is how you can track remote branches:

git branch --track dev-example origin/dev-example
git checkout dev-example
like image 39
Muhammad Junaid Avatar answered Oct 12 '22 23:10

Muhammad Junaid