2016-08-13 62 views
0

我想合并3个git回购与历史,然后我想能够推动2回购不同的分支,并向MainRepo进行合并请求。 我有MainRepo,ARepo和BRepo。我想将ARepo和BRepo合并到MainRepo中,因此我应该获得new_branch。 这个新的分支应该推到我的privateRepo。 另外,我希望能够推送一些分支(将在稍后作为稳定版本创建)到publicRepo。最后但并非最不重要我希望能够向MainRepo发出合并请求。 这是可能的,哇我应该配置git项目来实现这个?合并3 git回购,并能推入2个不同的回购

+0

'ARepo','BRepo'和'MainRepo'是否有共同的历史或结构?否则,您可能会发现合并它们是一项艰巨的任务。 –

+0

他们没有。一开始,我想到了将它们分开放入新项目中的模块。他们都使用maven结构。然后启动边际代码。 Main和B repo是github回购,私人回购将在bitbucket上托管。 –

回答

1

所以,我会用这样的一系列命令去,在MainRepo在本地:

> git checkout -b merge-others 
> git remote add ARepo https://a_repo.git # Replace with proper URL 
> git remote add BRepo https://b_repo.git # Replace with proper URL 

到目前为止,你所做的一切是由MainRepo知道别人的。现在这样做:

> git fetch ARepo 
> git fetch BRepo 

它从两个遥控器中检索分支/提交信息。然后,在适当的分支合并其他两个:

> git merge ARepo/master # Resolve any merge conflicts 
> git merge BRepo/master # Resolve any merge conflicts 

最后,你要推到你的私人和公共回购:

> git remote add privateRepo https://private_repo.git # Replace with proper URL 
> git push -u privateRepo HEAD 
> git remote add publicRepo https://public_repo.git # Replace with proper URL 
> git push -u publicRepo HEAD 

至于制作的MainRepo拉入请求,这取决于在你的平台上。如果你使用GitHub,这很简单,但我不能说其他平台。祝你好运!