将Git存储库从GitHub分叉到GitLab [英] Forking Git repository from GitHub to GitLab

查看:84
本文介绍了将Git存储库从GitHub分叉到GitLab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想对其他人的项目实施修复.该项目位于GitHub上.

Suppose that I would like to implement a fix to a project of someone else. That project resides on GitHub.

我可以在GitHub上创建一个fork并实现此修复程序.

I could create a fork on GitHub and implement the fix.

但是,我想在GitLab而不是GitHub上创建我的fork.

However, I would like to create my fork on GitLab rather than on GitHub.

有可能吗?怎么样?

我已经阅读了这篇文章: https://about.gitlab.com/2016/12/01/how-to-keep-your-fork-up-to-date-with-its-origin/

I have read this article: https://about.gitlab.com/2016/12/01/how-to-keep-your-fork-up-to-date-with-its-origin/

无论如何,我不确定我该怎么办.

Anyway, I am not sure what should I do in my case.

  • 我是否应该以某种方式在GitHub的项目的GitLab上创建一个fork?
  • 还是应该在GitHub上的项目的GitLab上创建镜像?
  • 还是应该在GitLab上创建一个镜像,然后分叉该镜像?
  • 还是应该做一些完全不同的事情?

正确的方法是什么

谢谢.

更新

GitLab上的存储库镜像可能没有意义.我可以在GitLab上创建MY GitHub存储库的镜像,但不能创建其他人的存储库的镜像.

Repository mirroring on GitLab does not make sense probably. I can create a mirror of MY GitHub repository on GitLab but I cannot create a mirror of a repository of someone else.

https://docs.gitlab.com/ee/workflow/repository_mirroring.html

这是我到目前为止所做的:

This is what I have done so far:

我已经将原始GitHub项目克隆到了本地机器上.我已将修复程序提交到本地存储库中的新分支.我在GitLab上创建了一个空项目.我已将本地存储库中的源设置为GitLab上的该空项目,并将两个分支都推送到GitLab.我已经在本地存储库中将上游设置为GitHub存储库.

I have cloned the original GitHub project to my local machine. I have commited the fix to a new branch in my local repository. I have created an empty project on GitLab. I have set origin in my local repository to that empty project on GitLab and pushed both branches to GitLab. I have set upstream in my local repository to the GitHub repository.

当我想将新的提交从原始GitHub存储库获取到GitLab上的存储库(即同步存储库)时,可以使用本地存储库作为中间步骤来进行此操作.但是,在GitHub上的存储库和GitLab上的存储库之间没有直接连接.我的设置正确吗?如果我在GitHub上进行分叉,有什么区别吗?

When I want to get new commits from the original GitHub repository to the repository on GitLab (i.e. sync the repositories), I can do this using my local repo as an intermediate step. However, there is no direct connection between the repo on GitHub and the repo on GitLab. Is my setup correct? Is there any difference if I make a fork on GitHub?

推荐答案

如果您只想跟踪更改,请先在GitLab(或您可能使用的其他任何工具)中建立一个空的存储库,然后将其克隆到计算机中.

If you just want to track changes, first make an empty repository in GitLab (or whatever else you may be using) and clone it to your computer.

然后将GitHub项目添加为"上游",并远程:

Then add the GitHub project as the "upstream" remote with:

git remote add upstream https://github.com/user/repo

现在,如果有任何更改,您可以从上游获取和拉取. (如果您具有访问权限,也可以将其推送或合并.)

Now you can fetch and pull from the upstream should there be any changes. (You can also push or merge to it if you have access rights.)

git pull upstream master

最后,回到您自己的GitLab存储库:

Finally, push back to your own GitLab repository:

git push origin master

如果您不想手动拉上游/推原点,则GitLab可在设置=>存储库=>镜像存储库中提供镜像功能.

这篇关于将Git存储库从GitHub分叉到GitLab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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