2

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.

Community
  • 1
  • 1
VSO
  • 11,546
  • 25
  • 99
  • 187

1 Answers1

5

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
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
  • That worked (the first one), can you explain why? I will accept the answer, but I am curious why git clone doesn't work without specifying the branch? – VSO Dec 21 '16 at 18:44
  • I pushed a master branch, deleted everything locally, and tried clone without the params again. Worked perfectly, thank you very much. – VSO Dec 21 '16 at 18:55
  • 1
    I think sajib already answered this: The repo you are cloning from does not contain a master branch, and the clone command defaults to trying to check out the master branch, which does not exist in this case. Therefore, specifying development fixes the problem. – Randy Leberknight Dec 21 '16 at 18:56
  • @VSO You can't `clone / pull / fetch` a bare repo. I've updated my answer. – Sajib Khan Dec 21 '16 at 18:56
  • Thanks guys - all is good. I didn't know the 'master' branch had any significance. Assumed it would just clone from dev, but apparently not. I pushed a master branch and now git clone works. – VSO Dec 21 '16 at 18:56