2016-08-13 60 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,這很簡單,但我不能說其他平臺。祝你好運!