将 git 存储库从 GitLab 转移到 GitHub - 我们可以,如何操作和陷阱(如果有)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22265837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:51:08  来源:igfitidea点击:

Transfer git repositories from GitLab to GitHub - can we, how to and pitfalls (if any)?

gitgithubtransfergitlabrepository

提问by boddhisattva

Can one transfer repositories from GitLab to GitHub if the need be. If so, how exactly can I go about doing the same?

如果需要,可以将存储库从 GitLab 转移到 GitHub。如果是这样,我该如何去做同样的事情?

Also, are there any pitfalls in doing so or precautionary measures that I need to keep in mind before doing so given that I may decide to eventually move them to GitHub (as it has more features at the moment that I might find handy for my project).

另外,这样做是否有任何陷阱或在这样做之前我需要记住的预防措施,因为我可能会决定最终将它们移动到 GitHub(因为它目前具有更多功能,我可能会发现对我的项目很方便) )。

回答by VonC

You can transfer those (simply by adding a remote to a GitHub repo and by pushing them)

您可以传输这些(只需将远程添加到 GitHub 存储库并推送它们)

  • create an empty repo on GitHub
  • git remote add github https://[email protected]/yourLogin/yourRepoName.git
  • git push --mirror github
  • 在 GitHub 上创建一个空仓库
  • git remote add github https://[email protected]/yourLogin/yourRepoName.git
  • git push --mirror github

The history will be the same.

历史将是一样的。

But you will loose the access control (teams defined in GitLab with specific access rights on your repo)

但是您将失去访问控制(在 GitLab 中定义的团队对您的存储库具有特定的访问权限)

If you facing any issue with the https URL of the GitHub repo:

如果您在 GitHub 存储库的 https URL 方面遇到任何问题:

The requested URL returned an error: 403

All you need to do is to enter your GitHub password, but the OP suggests:

您需要做的就是输入您的 GitHub 密码,但 OP 建议:

Then you might need to push it the ssh way. You can read more on how to do it here.

然后您可能需要以 ssh 方式推送它。您可以在此处阅读有关如何操作的更多信息。

See "Pushing to Git returning Error Code 403 fatal: HTTP request failed".

请参阅“推送到 Git 返回错误代码 403 致命:HTTP 请求失败”。

回答by manoj

This is very easy by import repository feature Login to github.com,

这很容易通过导入存储库功能登录github.com

Side of profile picture you will find +button click on that then there will be option to import repository. you will find page like this. enter image description hereYour old repository's clone URL is required which is gitlab repo url in your case. then select Owner and then type name for this repo and click to begin import button.

在个人资料图片的一侧,您会发现+单击该按钮,然后将有选项import repository。你会找到这样的页面。 在此处输入图片说明您的旧存储库的克隆 URL 是必需的,在您的情况下是 gitlab repo url。然后选择所有者,然后键入此存储库的名称,然后单击开始导入按钮。

回答by 1u-

If you want to migrate the repo including the wiki and all issues and milestones, you can use node-gitlab-2-githuband GitLab to GitHub migration

如果你想迁移包括 wiki 和所有问题和里程碑的 repo,你可以使用node-gitlab-2-githubGitLab 到 GitHub 迁移

回答by SamiX

I had the opposite problem and finally had to create my own bash shell script for the company to migrate the hundred of repos from Github to Gitlab due to a change in the company policy.
The script use the Gitlab API to remotely create a repo, and push the Github repo into it. There is no README.md file yet, but the sh is well documented.
The same thing can be done opposite way I imagine. Hope this could help.
https://github.com/mahmalsami/migrate-github-gitlab/blob/master/migrate.sh

我遇到了相反的问题,最后不得不为公司创建我自己的 bash shell 脚本,以便由于公司政策的变化将数百个 repos 从 Github 迁移到 Gitlab。
该脚本使用 Gitlab API 远程创建一个 repo,并将 Github repo 推送到其中。目前还没有 README.md 文件,但是 sh 有很好的文档记录。
同样的事情可以按照我想象的相反方式完成。希望这会有所帮助。
https://github.com/mahmalsami/migrate-github-gitlab/blob/master/migrate.sh

回答by Alex Mokrushin

If you have MFA enabled on GitLab you should go to Repository Settings/Repository ->Deploy Keys and create one, then use it as login while importing repo on GitHub

如果您在 GitLab 上启用了 MFA,您应该转到 Repository Settings/Repository -> Deploy Keys 并创建一个,然后在 GitHub 上导入 repo 时将其用作登录名