2013-08-29 138 views
1

當我最初分岔項目,並設置我的環境,我有這個。git推到分叉prj;拉請求到一個父分支

> git branch -a 

remotes/origin/HEAD -> origin/master 
remotes/origin/master 
remotes/upstream/master 

我沒有對上游項目的「推送」權限。我必須 從我的叉子發送拉請求。

一個星期後,創建了一個新的分支,用於對上游進行特定增強的工作。 該團隊可能會在這個分支工作數週。

remotes/origin/HEAD -> origin/master 
remotes/origin/master 
remotes/upstream/new-project-feature 
remotes/upstream/master 

什麼是適當的方式來設置和提交代碼到這個分支? 這就是我所做的。這是正確的做法嗎?

git branch new-project-feature 
git checkout new-project-feature 
git rebase upstream/new-project-feature 
.. code changes 
.. commit 
git push origin HEAD:new-project-feature 
.. go to github and send the pull request. 

如何父項目知道合併拉請求其 新項目的特性分支?

回答

0

背後拉請求的理念是:

    你在一個小的增強,你希望看到合併到上游分支
  • 你推的是增強你的叉子(origin)工作
  • ,並從那裏

fork

但要拉入請求:

您應該在目標分支中的專用分支,而不是中進行增強。
這意味着,在不masternew-project-feature:這些是「目標」分支,其在你的叉,在那裏upstream repo,爲「remote trackupstream/masterupstream/new-project-feature

所以,你應該做一個或幾個分支,每一個你想參與new-project-feature一個小的變化,推動一個小分支「small_change」,並進行了拉請求upstream/new-project-feature

您可以定期拉upstream,更新您當地的new-project-feature與最新的上游/新項目功能。
然後,您可以在更新的new-project-feature分支頂部重新分配您的「small_changes」分支,然後繼續進行工作。

注意,如果new-project-feature改變上游後,你已經做出從叉你拉的要求,所有你需要做的是:

  • 獲取和更新本地new-project-feature分支
  • 衍合small_change新項目功能之上的分支
  • 檢查一切仍然有效
  • git push --force origin small_change

最後一次強制推送會自動更新您的推拉請求:您不必再做第二次推拉請求
查看更多「How to do a Github pull request?」。