从Gitlab镜像到Github [英] Mirroring from Gitlab to Github

查看:366
本文介绍了从Gitlab镜像到Github的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用一个私有的Gitlab实例来保存我所有的代码。但是,由于现在大多数与我一起工作的员工都有一个Github账户,我真的想要移动并将我的Gitlab回购库镜像到Github上。



我的情况:




  • 运行Gitlab(Omnibus)的服务器

  • 创建组织的Github帐户因为我和我的员工可以组织在一起。



我知道有 - mirror 在git中切换,但我不确定这是如何工作的。我在网上找到的文件非常奇怪......所以如果有人能够帮助我,这将是很好的。 :)

解决方案

这个以前的StackOverflow 问题解决了如何将你的版本库从另一个服务移动到GitHub,第一个答案是通过如何通过GitHub命令行,第二个和第三个是用户友好的方式,如果你的GitLab实例在你的本地服务器上(这似乎是你的情况),那么很不幸你的工作不可用。



然而,您可以按照 by GitHub docs ,这是建议的方式,作为GitHub 提供这个替代方法来使用他们的GitHub Impor (在前面的SO问题中突出显示)



从文档中提取的步骤:


  1. 创建一个新的存储库您希望推送到GitHub中。 从您的GitLab服务器制作本地裸机克隆:
    $ b

    git clone --bare https://githost.org/extuser/repo.git


裸露克隆是完全重复的,没有用于编辑文件的工作目录,所以它是一个干净的导出。


  1. 切换到该目录,然后用 - mirror 标志。 镜像标志确保引用(分支/标签)被复制到GitHub。
    $ b cd * repo.git *



    git push --mirror https://github.com/ghuser/repo.git


  2. 最后删除您所做的本地存储库。

    cd ..



    rm -rf repo.git



I have been using a private Gitlab instance to hold all my code. But since most of the staff that work with me now have a Github account, i would really like to get moving and mirror my Gitlab repo to Github.

My situation:

  • a server running Gitlab (Omnibus)
  • a Github account for which I'll create an organization for where me and my staff can be organized together.

I know that there is the --mirror switch in git, but I am not really sure how this is ment to work. Documentation I found online was very wonky... So it would be nice if someone could help me out. :)

解决方案

This previous StackOverflow question addresses how to move your repository from another service over to GitHub, the first answer there addresses how to do it via command line, and the second and third are more user friendly ways, which unfortunately will not work for you if your GitLab instance is on your local server (which seems to be your case).

You can however 'import' your repository from the command line to GitHub as explained by GitHub docs, this is the suggested way as GitHub offers this as an alternative to using their GitHub Importer tool (which is highlighted in that previous SO question)

A run down of steps as taken from the documentation:

  1. Create a new repository you want to push to in GitHub.
  2. Make a local bare clone from your GitLab server:

    git clone --bare https://githost.org/extuser/repo.git

A bare clone is an exact duplicate, without a working directory for editing files, so it's a clean export.

  1. Change into that directory and then push it with the --mirror flag. The mirror flag ensures that references (branches/tags) are copied to GitHub.

    cd *repo.git*

    git push --mirror https://github.com/ghuser/repo.git

  2. Finally remove the local repository you made.

    cd ..

    rm -rf repo.git

这篇关于从Gitlab镜像到Github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆