一千萬個為什麽

搜索

Git分支模型適合您?

我們公司目前正在使用簡單的主幹/發布/修補程序分支模型,並希望了解哪些分支模型最適合您的公司或開發過程。

  1. Workflows/branching models

    Below are the three main descriptions of this I have seen, but they are partially contradicting each other or don't go far enough to sort out the subsequent issues we've run into (as described below). Thus our team so far defaults to not so great solutions. Are you doing something better?

  2. Merging vs rebasing (tangled vs sequential history)

    Should one pull --rebase or wait with merging back to the mainline until your task is finished? Personally I lean towards merging since this preserves a visual illustration of on which base a task was started and finished, and I even prefer merge --no-ff for this purpose. It has other drawbacks however. Also many haven't realized the useful property of merging - that it isn't commutative (merging a topic branch into master does not mean merging master into the topic branch).

  3. I am looking for a natural workflow

    Sometimes mistakes happen because our procedures don't capture a specific situation with simple rules. For example a fix needed for earlier releases should of course be based sufficiently downstream to be possible to merge upstream into all branches necessary (is the usage of these terms clear enough?). However it happens that a fix makes it into the master before the developer realizes it should have been placed further downstream, and if that is already pushed (even worse, merged or something based on it) then the option remaining is cherry-picking, with its associated perils. What simple rules like such do you use? Also in this is included the awkwardness of one topic branch necessarily excluding other topic branches (assuming they are branched from a common baseline). Developers don't want to finish a feature to start another one feeling like the code they just wrote is not there anymore

  4. How to avoid creating merge conflicts (due to cherry-pick)?

    What seems like a sure way to create a merge conflict is to cherry-pick between branches, they can never be merged again? Would applying the same commit in revert (how to do this?) in either branch possibly solve this situation? This is one reason I do not dare to push for a largely merge-based workflow.

  5. How to decompose into topical branches?

    We realize that it would be awesome to assemble a finished integration from topic branches, but often work by our developers is not clearly defined (sometimes as simple as "poking around") and if some code has already gone into a "misc" topic, it can not be taken out of there again, according to the question above? How do you work with defining/approving/graduating/releasing your topic branches?

  6. Proper procedures like code review and graduating would of course be lovely.

    But we simply cannot keep things untangled enough to manage this - any suggestions? integration branches, illustrations?

以下是相關問題列表:

還可以查看Plastic SCM在任務驅動開發上寫的內容,以及Plastic不是你的選擇,研究 nvie的分支模型和他的支持腳本

最佳答案

DVCS新開發人員需要意識到的最令人不安的功能是關於發布過程

  • 您可以導入(獲取/拉取)您需要的任何遠程倉庫
  • 您可以發布(推送)到您想要的任何(裸)回購

從那以後,您可以遵守一些規則來簡化您的問題:

現在:

Workflows/branching models:

每個工作流程都可以支持發布管理流程,並為每個項目量身定制。
我可以添加到您提到的工作流程中的是:每個開發人員都不應該創建一個功能分支,只能創建一個“當前開發”分支,因為事實是:開發人員通常不知道他/她的分支將產生什麽:一個功能,幾個(因為它最終是一個太復雜的功能),沒有(因為沒有及時準備發布),另一個功能(因為原來的一個“變形”),...

只有“集成商”應該在“中央”倉庫上建立官方功能分支,然後開發人員可以獲取這些分支來修改/合並適合該功能的部分工作。

Merging vs rebasing (tangled vs sequential history):

我喜歡你提到的答案(“ git的工作流程描述用於內部開發“)

I am looking for a natural workflow:

對於修復,它可以幫助將每個修復程序與來自錯誤跟蹤的故障單相關聯,這有助於開發人員記住他/她應該進行此類修改的位置(即哪個分支,即專用分支“for fixes”)。
然後,鉤子可以幫助保護中央倉庫免受來自未經驗證的錯誤修復或來自不應該推送的分支的推送。 (這裏沒有具體的解決方案,所有這些都需要適應您的環境)

如何避免創建合並沖突(由於挑選)?

正如JakubNarębski所述他的回答,櫻桃采摘應該保留在需要它的罕見情況下。
如果您的設置涉及大量采摘(即“它並不罕見”),那麽就會出現問題。

在revert中應用相同的提交(如何做到這一點?)

git revert should take care of that, but that is not ideal.

如何分解成主題分支?

只要一個分支尚未被推到任何地方,開發人員應該重新組織其提交歷史(一旦他/她最終看到開發需要更明確和穩定的形狀):

  • 如果需要,可以使用多個分支(一個通過明確標識的功能)
  • 一個分支內的一系列一致提交(請參閱修剪Git簽名

正確的程序,如代碼審核和畢業?

集成分支(在專用集成中)repo可以幫助開發人員:

  • 在遠程集成分支(pull --rebase)
  • 之上修改他/她的開發
  • 解決本地問題
  • 將開發推送到該回購
  • 與積分器核實不會造成混亂;)

轉載註明原文: Git分支模型適合您?