![](/img/trans.png)
[英]Will git log --cherry-pick --right-only --no-merges ignore all commits correctly cherry-picked between branches?
[英]git cherry-pick all missing commits between two branches from the same master
我有以下情況:
兩個分支是在不同時間從 master 創建的
T0 T1
----+-----------------+------> master
| |
| |
+---- BranchA +---- BranchB
在時間 T0 之后在 BranchA 上進行開發
一些但不是所有這些提交在時間 T0 之后但在時間 T1 之前合並到 master 中
我現在想將 BranchA 中不存在於 BranchB 中的所有提交挑選到 BranchB 中
未經測試,但是
git switch BranchB # Use git checkout BranchB if you prefer.
git cherry-pick ..BranchA
應該管用。 取自https://git-scm.com/docs/git-cherry-pick的示例部分。
而不是櫻桃采摘,變基。
首先,將 branchA 變基到 master 上。
這使 branchA 保持最新狀態。 毫無疑問,branchA 的哪些部分在 master 中。 毫無疑問,它們是否與 master 兼容。
這將大大簡化流程,並讓您有機會解決 branchA 和 master 之間的任何沖突,而無需涉及 branchB。
將 branchB 變基到 master 可能也是一個好主意,以確保兩個分支都是最新的並且在公共基礎上工作。
然后將 branchB 變基到 branchA。 或相反亦然。 或者 cherry pick master..branchA(所有不在 master 中的 branchA 上的提交)到 branchB 上。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.