VSO
VSO

Reputation: 12636

Github Clone Repo Error: warning: remote HEAD refers to nonexistent ref, unable to checkout

I was attempting to copy foo repo into new fooBar repo. I am running into an error, here is what I did:

  1. Created a new blank repo on github called fooBar
  2. Manually created a copy of the foo folder (the repo I wanted to copy) in same dir as foo locally.
  3. Renamed the copiedfoo(Copy) to fooBar locally.
  4. cd fooBar and ran git remote rm origin as per How to remove origin from git repository (which might have been a mistake, because I am just using github, not git-svn)
  5. Pushed my branch to my new remote fooBar repo like so: git remote add origin https://github.com/myteam/fooRepo.git git push -u origin development (Note that I used development instead of master - I thought master doesn't have any significance and is just a convention)
  6. Finally I deleted my fooBar folder once I saw it has pushed to github successfully. I then tried pulling it git clone https://github.com/myAccount/fooBar.git

I then get the following:

Cloning into 'fooBar'...
remote: Counting objects: 9297, done.
remote: Compressing objects: 100% (1727/1727), done.
remote: Total 9297 (delta 7542), reused 9297 (delta 7542), pack-reu
Receiving objects: 100% (9297/9297), 1.58 MiB | 253.00 KiB/s, done.
Resolving deltas: 100% (7542/7542), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

I can't find an answer for the highlighted error when cloning - everyone seems to have a problem when deleting a remote branch and trying to pull it.

warning: remote HEAD refers to nonexistent ref, unable to checkout.

Note, in my new fooBar repo, development is the only branch and it's set Default.

Upvotes: 2

Views: 4079

Answers (1)

Sajib Khan
Sajib Khan

Reputation: 24136

While cloning a repo default branch is master. But your master is bare (no working or checked out copy of your source files). All the codes are in development branch.

So, you need to mention development branch while cloning. Or, you need to push a master branch.

Try this:

$ git clone https://github.com/myAccount/fooBar.git --branch development

Or,

 $ git clone https://github.com/myAccount/fooBar.git --branch development -b development --single-branch

Upvotes: 5

Related Questions