Git 分支工作流程的範例
當然您需要建立最適合您團隊的分支策略。但這裡有一個快速範例,說明如何遵循涉及兩種類型分支的分支策略工作流程:開發/整合分支和功能/主題分支。
假設當有人在生產中發現 bug 時,您正在開發一項新功能,並且您必須在開發新功能的同時修補該 bug。

在開始修補 bug 之前,您先從開發分支建立一個新分支。這個新分支將修補 bug 與您正在處理的新功能隔離開來。

當準備發布 bug 修補時,將 bug 修補功能的分支合併到開發分支中。

然後切換回原來的功能分支,並繼續處理新功能。

在功能分支上,您注意到需要提交「X」,即 bug 修補提交,才能繼續執行新功能。換句話說,您必須將目前分支與開發分支上的更改同步。
有兩種選擇可以做到這一點:第一種是將包含提交「X」的開發分支與目前分支合併;第二個選項是將目前分支變基到包含提交「X」的開發分支。
對於此範例,您使用變基的方法。

一旦您在當前工作目錄中有了「X」,您就可以再次安全地開始使用新功能。