2015-06-16 34 views
0

我確定有很多文檔,但沒有任何東西顯示給我看。如何合併2 github存儲庫以觸發pullrequest?

我想貢獻開源項目,第一次做一個真正的公關。 (遲到比永遠好)。要開始簡單,我只想做某人在github fork上做的工作(但並沒有推回給master),做一些小的更新,然後嘗試製作PR到原始存儲庫

碩士回購是(R1):

叉形和更新回購是(R2):(注意:在一個特定的分公司)

我分岔的ageneau回購我的帳戶

我的意圖是:

  1. 要做到R2中的一個分支在我的github accoun上t =我沒有成功。它總是讓我沒有興趣的分支R1。該怎麼辦 ? 我其實已經加了R1叉。所以我刪除了R1叉和成功到餐桌R2我Github上

  2. 然後獲取本地回購:
    git clone https://github.com/afaucogney/loopback-sdk-android.git

  3. 添加起源
    git init
    git remote add origin https://github.com/afaucogney/loopback-sdk-android.git

  4. 添加上游(Strongloop版本)
    git remote add origin https://github.com/strongloop/loopback-sdk-android.git

  5. 創建本地分支
    cd loopback-sdk-android
    git branch firstpr
    git checkout firstpr

然後做什麼,我希望

git的變基上游產地......但什麼有趣的發生。

請告訴我的過程以及git命令。

回答

2

讓我們看到了非常詳細的工作:

  1. 叉在Github上,通過點擊「叉」按鈕,提供解決方案,回購:

    enter image description here

    所以,你得到一個叉你的Github賬戶(在這裏稱爲R3)賬戶如下:

    enter image description here

  2. 在Github上,做一個拉動請求:

    enter image description here

    其中:

    • 基回購是MilleZimTech fix_flatten分支(具有在溶液)
    • 比較回購是Strongloop(R1)主分支

    就像那樣(所有提交由Stronglo完成由於Ageneau叉OP):

    enter image description here

  3. 點擊 「創建拉請求」:

    enter image description here

  4. 公關不能自動合併:

    enter image description here

  5. 克隆y上的分支我們的本地計算(注意,程序與Github提出的程序不同)。使用--branch <branch-name>克隆一個特定的分支

    git clone https://github.com/MilleZimTech/loopback-sdk-android.git --branch fix_flatten
    cd loopback-sdk-android
    git branch

    您應該看到 'fix_flatten' 分支

  6. 與主回購在它創建一個新的分支:

    git checkout -b strongloop-master fix_flatten git pull https://github.com/strongloop/loopback-sdk-android.git master

    如有衝突。

    git status向您顯示被修改或不被修改的文件。
    git add .添加新文件。
    git commit -am"merge fix_flatten master"提交更改。
    再次git pull https://github.com/strongloop/loopback-sdk-android.git master

  7. 交換機的fix_flatten分支

    git checkout fix_flatten

  8. 合併沒有快進兩個分支合併

    git merge --no-ff strongloop-master

    你應該看到:

    enter image description here

  9. 推回GitHub庫

    git push origin fix_flatten

  10. 如果你克隆回購用git://,而不是https://開頭,你需要:

    git remote set-url --push origin https://github.com/MilleZimTech/loopback-sdk-android.git,使用--push' because without, only the源存儲庫的fetch參數將被更新。

    ,並再次git push origin fix_flatten

  11. 然後看到像

    enter image description here

  12. 在Github上的變化,這是fix_flatten分支是最新的,請在主分支pull請求我回購。

    選擇fix_flatten分支,那麼我們可以看到:

    enter image description here

  13. 點擊PullRequest

    • 基地master分支
    • 比較fix_flatten分支
  14. 合併和確認PullRequest

    enter image description here

  15. 然後你就可以放心地PullRequest回購Strongloop

    enter image description here

結束:

Ouuuf ...這是很難找到並描述。但我認爲這可以幫助不熟悉git的人。從來沒有,我不明白爲什麼這是如此複雜和漫長。

有沒有人有更直接的方式來做這種平常的任務?

1

讓我看看我是否理解正確。你是否嘗試過讓R2先刪除以前不需要的分叉?

編輯: 這裏的問題是,你分叉兩個回購,只有第二個是必需的,因爲是一個包含你需要的分支。

在這一點上,你有兩種選擇: 1.-刪除你在你的github帳戶上做的叉子,並再次只叉R2。 2.-將R2添加爲遠程,並使git fetch R2獲得僅R2上的那些分支。

+1

是的,這是第一個子問題,我通過刪除解決。最後我明白了我需要fork的repo是處理更新的解決方案(R2)而不是master(R1)的。因爲你可以擁有同名的2回購。 – Anthony

+0

檢查我自己的詳細解決方案。請隨時快捷! @Oscar – Anthony