簡體   English   中英

將分支變基或合並到合並到 master 中的另一個功能分支上

[英]Rebase or merge a branch onto another feature branch merged in master

我正在處理一個功能分支場景,我有點不確定將 go 作為“最佳解決方案”的方式。

a -- b -- c                               <-- Master
           \
            d  -- e  -- f                 <-- Branch 1 (in review)
             \            
              d -- e -- f -- g -- h       <-- Branch 2

我開始在Branch 1上工作,完成了完整的實現,並打開了拉取請求。 但是,我需要創建Branch 2來啟動功能實現的第二部分。

a -- b -- c               x               <-- Master
           \             /
            d  -- e  -- f                 <-- Branch 1 (Merged in Master)
             \            
              d -- e -- f -- g -- h       <-- Branch 2

這樣, Branch 1被 CI 合並到主分支中。 問題是Branch 2加載了Branch 1中的所有更改,我不知道將 Master 更改合並到我的Branch 2中的方式。

交互式變基還是合並?

非交互式變基應該足夠了

首先,確保您的本地master服務器與“ upstream ”/ master服務器是最新的( upstream是遠程引用目標存儲庫,您的 PR 已在其中合並)

git switch master
git fetch upstream
git merge upstream/master

然后重播branch1啟動后完成的每個branch2提交,並在更新后的master之上重播它們。

A git merge-base branch1 branch2應該給你提交d of branch1

git rebase --onto master $(git merge-base branch1 branch2) branch2

這樣,你得到:

                            d' -- e' -- f' -- g' -- h'   <-- Branch 2
                           /
a -- b -- c               x               <-- Master
           \             /
            d  -- e  -- f                 <-- Branch 1 (Merged in Master)           

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM