Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clone a github repo into a private gitlab repo

Tags:

git

github

gitlab

I am trying to pull a repo from github and push it up to a private repo on a gitlab server that I am running.

I cloned the github repo to my local machine

git clone  https://github.com/somepage/someproject

at that point I added a new remote (my gitlab)

git remote add gitlab https://mygitlabserver/mypage/myproject

then I pushed (in this case only branch on githab was develop)

git push gitlab develop

Now I am running into problems when I try to clone from my gitlab repo:

git clone https://mygitlabserver/mypage/myproject
Cloning into 'myproject'...
remote: Counting objects: 140, done.
remote: Compressing objects: 100% (85/85), done.
remote: Total 140 (delta 40), reused 140 (delta 40)
Receiving objects: 100% (140/140), 2.75 MiB | 1.85 MiB/s, done.
Resolving deltas: 100% (40/40), done.
Checking connectivity... done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Not 100% what that warning is about, but I am sure its not good. If I list the contents of that cloned dir its empty.

What did I do wrong?

like image 474
lostintranslation Avatar asked Apr 03 '15 14:04

lostintranslation


People also ask

Can private repositories be cloned?

You also have the option to clone a private GitHub repository using SSH. To do this, you need to start by generating an SSH keypair on your local device. Then add a public key to your GitHub account. This gives you the ability to connect your local device with GibHub using a secure channel over an unsecured network.


1 Answers

I suspect you are getting that error because the default configuration of a repository in gitlab is to have a default branch name of master. You have only pushed a branch named develop, and when you clone the repository git is attempting to checkout the nonexistent master branch.

You can:

  • go into the repository settings in gitlab and set the default branch to develop,

  • or you can just name the branch master,

  • or you can provide -b develop to the git clone command,

  • or after cloning you can simply git checkout develop.

like image 158
larsks Avatar answered Oct 19 '22 03:10

larsks