假設,我有以下分支
B---C---D---E---F---G feature
/ / \
--A---F---G---H----I------J master
有一個特性分支,它通過將 master 合并到特性(合并提交 B 和 E)從 master 定期重繪 。并且當特性準備好時,它被合并到主控中(合并提交 J),所以在這一點上特性和主控是等價的。
我想查看或記錄僅在沒有合并提交(B 和 E)的功能分支上發生的更改。那么有什么方法可以讓我只查看功能分支組合上的更改。
謝謝。
uj5u.com熱心網友回復:
git log --first-parent --no-merges A..feature
有任何你想要的細節,也許--oneline --patch。
這里沒有方便的命令可以找到A,第一父合并基礎,兩個技巧的第一父祖先中的最新提交,但它很容易做到:
merge-base-first-parent() {
( git rev-list --first-parent $1;
git rev-list --first-parent $2
) | awk 'seen[$1] {print $1;exit}'
}
git log --first-parent --no-merges --oneline --patch \
$(merge-base-first-parent master feature)..feature
在很長的歷史中,您可以通過 rev-list 和對退化案例的特殊處理變得可愛,--parents使其始終快速運行。
要將更改視為單個差異,您必須構建沒有合并的提示的外觀。這很容易做到,你可以
git checkout A
git rev-list --reverse --no-merges A..feature | git cherry-pick -n --stdin
git diff @
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/483498.html
