2017-07-29 120 views
0

我一直在Google上搜索幾個小時,試圖找到方法。git - 合併分支從remoteRepo到本地分支

我在gitlab上得到了一個回購,希望在gitlab回購中將一個從github合併到我的分支中。 comitting合併,或的方式同樣

比如:https://github.com/repo/server

合併分支「莎拉」到myServer上

其中myserver是我的分支,莎拉是鏈接分支和鏈接是回購

謝謝您提前。 PS。我很喜歡這個主題,用戶友好!

回答

3

添加遠程到你的Git實驗室回購。基於myServer

git checkout -b temp gitlab/myServer 

git remote add gitlab https://gitlab.com/user/repo.git 
git fetch gitlab 

遠程添加到Git的樞紐

git remote add github https://github.com/user/repo.git 
git fetch github 

結帳新temp分支合併合併Sarah和解決衝突等

git merge github/Sarah 

現在,您可以隨意爲您的temp分支做任何事情。就像推送給Git Lab一樣。

git push gitlab temp 

或者,如果你喜歡它,那麼你可以「覆蓋」你myServer分支迫使分支名指向這個承諾。

git branch -f myServer 

,然後推動,爲Git的實驗室(您可能需要根據上下文來強制)

git push gitlab myServer 
+0

致命:pathspec '遠程' 未找到任何文件 :S C:\文件\ myRepo? – Sarah

+0

@Sarah哎呀,對不起,這是一個錯字。應該是'git remote add ...' –

+0

最有可能的是從GitHub或GitLab中克隆本地回購。這意味着在技術上你不需要添加兩個遙控器,因爲其中一個已經是「原點」。當然,添加具有這些特定名稱的遙控器使得它更清楚哪個是哪個。 –