简体   繁体   English

git将一个仓库内容分叉到另一个仓库的分支中

[英]git fork a repo content into branch of another repo

Say there is a repo A with just a branch master.There is another repo which is fork of repo A.This repo is called B. 假设有一个只有分支主服务器的仓库A,另一个仓库是仓库A的分支,这个仓库称为B.
B's master branch has certain new commits but is far behind the repo A. B的master分支具有某些新提交,但远远落后于回购A。
I have to make a new branch in repo B with the contents of master branch of A. 我必须使用A主分支的内容在回购B中创建一个新分支。
I will have to pull in latest changes from repo A from time to time into this new branch. 我将不得不不时地将来自回购A的最新更改引入这个新分支。
I have cloned repo A to my computer, made some changes.Now this has to go to the new branch of B over github. 我已经将仓库A克隆到我的计算机上,进行了一些更改,现在必须转到github上B的新分支。 How do I do this ? 我该怎么做呢 ?
I tried looking at other questions but couldn't grasp it being a git newbie. 我尝试查看其他问题,但无法理解它是git新手。

git branch master-of-a
git fetch upstream master:master-of-a

I would not do it like that if I were you, though. 但是,如果我是你,我不会那样做。 I would work, in B, in branches only. 我只会在B分支机构工作。 And I would synchronize A's master branch to B's master branch. 然后我将A的master分支同步到B的master分支。 It's much more traditional, and less confusing, to have the two master branches contain the same thing. 让两个主分支包含相同的东西是更传统的且不那么混乱。

If you submit the changes made in one of B's branches and it ends up being accepted in repo A, then it will be merged to A's master branch, and you can then just synchronize B's master branch with A's, and delete the accepted branch. 如果您提交了在B的一个分支中所做的更改,并且最终在回购A中被接受,那么它将被合并到A的master分支中,然后可以将B的master分支与A的同步,然后删除接受的分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM