2014-02-14 40 views
1

還有別人的回購與麻省理工學院許可的項目,我已經分叉它並提交拉請求一段時間,其他貢獻者也推動他們在那裏的變化,但我的分支主分支沒有所有這些變化(我爲每個新的拉取請求推入一個新的分支)。如何在Github上將原始倉庫中的更改重放到我的貨叉上?

所以我想從原始倉庫的所有更改都重播在我的貨叉的主分支上。下列職位會做什麼?

git checkout master 
git pull --rebase SomeoneElsesRepo master 
git push MyFork master 

我是否能夠不被歸因於拉請求git pull拉到變化提出引入請求(因爲它被描述in this question)?

回答

3

這裏有一個Github Guide

TL; DR:

git remote add upstream https://github.com/<otheruser>/<repo>.git 
git fetch upstream 

選項A)如果你喜歡的合併:

# assuming you're on master 
git merge upstream/master 
git push origin # assuming origin is your fork 

選項B)如果你寧願變基:

# assuming you're on master 
git rebase upstream/master 
git push origin # this might fail with a 'non-fast-forward' error 
    # in which case, insert --force after the word 'push' 

關於拉請求(PR):

PR將始終包含您的分支中並且不在目標分支中的所有提交。如果您在目標分支中沒有提交的提交中重定位/合併? Yeap,他們會出現在PR中。不希望發生這種情況?在PR中只需提交您想要的提交到新分支。 (Srsly,在谷歌和這裏有一個bazillion指南。)

+0

當使用'rebase'(與另一個本地回購)我不斷收到錯誤,指出遠程分支不明確或不是單個修訂。我使用'git show-ref'修復了它,然後輸入我想要的遠程分支的名稱(右列值),如'git rebase refs/remote/name of remote>/'。 –

相關問題