如何将一个分支从一个GitHub存储库复制到另一个? [英] How to copy a branch from one GitHub repository to another?

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

问题描述

作者有一个存储库,称为Master。

The Author had a respository, called Master.

我分叉了Master,并在其上创建了分支A。

然后,作者创建了一个组织,向该组织分叉了Master,并说应该是新的官方主存储库。

I forked Master, and created branch A on it.
Then the Author created an Organization, forked Master to the Organization, and said that that should be the new official main repository.

然后他邀请我加入本组织,现在我拥有提交权限。

Then he invited me to join the Organization and now I have commit access.

我想将我的分支A复制到组织存储库中,以便拥有分支A(即不集成分支),但是环顾四周,我似乎找不到任何简单的方法来做到这一点。

I'd like to copy my branch A onto the Organization repository so that it will have branch A, (ie. not integrating the branch,) but looking around, I can't seem to find any simple way to do this.

我的版本和组织版本都是从Master分支的,因此复制分支应该很简单,但是当我在线搜索说明时可以找到所有内容似乎所有关于将分支复制到您的存储库的本地副本,这不是我想要的。

Both my version and the Organization version were forked from Master, so it should be pretty straightforward to copy the branch over, but everything I can find when I search for instructions online seems to be all about copying branches to your local copy of the repository, which isn't what I'm trying to do.

有人知道怎么做吗?

推荐答案


我想将分支A复制到组织存储库中,以便它具有分支A(即不集成分支),但是环顾四周,我似乎找不到任何简单的方法来

I'd like to copy my branch A onto the Organization repository so that it will have branch A, (ie. not integrating the branch,) but looking around, I can't seem to find any simple way to do this.

只需将新的远程服务器(组织)添加到旧的存储库(主服务器)中。

一次您只需将分支A推到新的(组织)存储库中即可。

Simply add the new remote (Organization) to your old repository (master).
Once you did it simply push the branch A to the new (organization) repository.

cd <old repository>
git remote add origin2 <new_url>
git push origin2 <branch A>

现在,您应该在新存储库中拥有新的分支A。

Now you should have the new branch A in your new repository.
The point is to add new remote and to push the branch to your new repository.

第二种方法ID来更新当前存储库远程以指向新位置。

Second way id to update the current repository remote to point to the new location:

git remote set-url origin <new url>

然后推动分支。

上面两个都将具有相同的结果。区别在于,在第一个中,您添加了新遥控器,而在第二个中,您更改了遥控器。

Both of teh above will have the same result. The difference is that in the first one you add new remote while in the second one you change the remote.

这篇关于如何将一个分支从一个GitHub存储库复制到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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