简体   繁体   English

将github repo克隆到私有gitlab repo中

[英]Clone a github repo into a private gitlab repo

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. 我试图从github拉回一个repo并将其推送到我正在运行的gitlab服务器上的私有仓库。

I cloned the github repo to my local machine 我将github repo克隆到我的本地机器上

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

at that point I added a new remote (my gitlab) 那时我添加了一个新的遥控器(我的gitlab)

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

then I pushed (in this case only branch on githab was develop) 然后我推(在这种情况下只有githab上的分支开发)

git push gitlab develop

Now I am running into problems when I try to clone from my gitlab repo: 现在,当我尝试从我的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. 不是100%的警告,但我确信它不好。 If I list the contents of that cloned dir its empty. 如果我列出克隆目录的内容为空。

What did I do wrong? 我做错了什么?

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 . 我怀疑你收到了这个错误,因为gitlab中存储库的默认配置是默认的分支名称为master You have only pushed a branch named develop , and when you clone the repository git is attempting to checkout the nonexistent master branch. 您只推送了一个名为develop的分支,当您克隆存储库时,git正在尝试检出不存在的master分支。

You can: 您可以:

  • go into the repository settings in gitlab and set the default branch to develop , 进入gitlab的存储库设置并设置默认分支进行develop

  • or you can just name the branch master , 或者你可以命名分支master

  • or you can provide -b develop to the git clone command, 或者你可以提供-b developgit clone命令,

  • or after cloning you can simply git checkout develop . 或克隆后你可以简单地git checkout develop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM