如何在已有主人的情况下从回购协议中分支新分支? [英] How to fork a new branch from a repo when you already have the master?

查看:135
本文介绍了如何在已有主人的情况下从回购协议中分支新分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将repo分叉到我自己的github帐户中,并已成功将其拉到我的PC上,但是现在有一个原始repo上的新分支,我也想要,但是当我尝试分支该分支时,它需要我的github帐户上的主分支没有真正做任何事情。如何在我的账户中获得两个分支机构。

解决方案

一旦你克隆了你的分支,你可以在你本地克隆的repo add一个新的远程引用原始回购(您已经分叉的一个,以及刚刚出现一个新兴趣分支的回购)

这是



您所做的是:

  cd / path / to / local / repo 
git remote add upstream / url / of / original / repo
git fetch

最后一次读取将包括新分支(在 remotes / upstream 命名空间中)



从那里,你可以很容易地创建一个从 upstream / newBranch 开始的本地分支,并将它推送到你的fork(由远程名为' origin ')

  git checkout -b newBranch upstream / newBranch 
git push -u origin newBranch


I have forked a repo into my own github account and have successfully pulled it to my PC, however there is now a new branch on the original repo that I want as well but when I try to fork that branch, it takesme to the master branch on my github account without actually doing anything. How do I get both branches on my account.

解决方案

Once you have cloned your fork, you can on your local cloned repo add a new remote referencing the original repo (the one you have forked, and the one where a new branch of interest just appeared)

It is the triangular workflow:

What you do is:

cd /path/to/local/repo
git remote add upstream /url/of/original/repo
git fetch

That last fetch will include the new branch (in the remotes/upstream namespace)

From there, you can easily create a local branch starting from that upstream/newBranch and push it to your fork (referenced by the remote named 'origin')

git checkout -b newBranch upstream/newBranch
git push -u origin newBranch

这篇关于如何在已有主人的情况下从回购协议中分支新分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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