Reputation: 2264
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 non-empty changes on Dec. 6 (although now that branch isn't showing on a --single-branch
clone attempt). After ssh-ing into the Git repository, there is plenty of files and folders there.
So, my questions:
Upvotes: 16
Views: 76336
Reputation: 711
I ran into the same issue that turned out to be a from a race condition:
gh repo create xxx --template template-name
gh repo clone xxx
This resulted in cloning of empty repositories.
By adding a delay (I did 15 seconds but I'm sure a much smaller interval would work)
gh repo create xxx --template template-name
sleep 15
gh repo clone xxx
Upvotes: 0
Reputation: 213
I encountered the same issue after migrating to a new Gitlab server.
It has been fixed after performing the steps below.
For example, if the project Git URL is http://gitlab.abc.work/neptune-open/neptune-developer-guide.git
git clone [email protected]/neptune-open/neptune-developer-guide.git
vi
):
vi neptune-developer-guide/.git/config
Then change the "origin" url to http format:
[remote "origin"]
url = http://gitlab.abc.work/neptune-open/neptune-developer-guide.git
cd neptune-developer-guide && git add . && git commit -m "fix git clone issue"
git push origin master
Upvotes: 0
Reputation: 294
A colleague of mine just had a similar issue. Frankly, I have no idea why it happened, since a simple HTTPS cloning worked for the rest of our team. But, ultimately, here's a solution that helped - instead of git clone
we had to do basically the same, but manually:
project/
project/
, run git init
git remote add origin https://github.com/yourAccount/yourrepo.git
git pull origin master
Upvotes: 0
Reputation: 9718
In my case it was a silly mistake when I've tried to clone a repo from another machine: I've used https
instead of ssh
as protocol in the URL. Surprisingly I've got no error, but the message “You appear to have cloned an empty repository”.
Upvotes: 0
Reputation: 704
This happens when you are cloning a freshly created repository with no commits.
As it says, it is just a warning. If it is expected that there is nothing in the repository, you can go ahead and add files and commit and push back.
If it is not supposed to be empty, contact the person/admin who gave you the link.
Upvotes: 4
Reputation: 504
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
Upvotes: 6
Reputation: 17430
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.
Upvotes: 10