Git diff分支针对不包含合并的工作树 [英] Git diff branch against working tree not including merges
问题描述
<$ c $ 我试图找出当前工作树与另一个分支(例如master)之间的差异。 C>。 --a - > 。 --b - > 。 (主)
\\
c \(合并)
\\
。 -----。 --D - > 。 (当前) - e - > (工作树)
现在, git diff master
确实显示工作树的变化,但是它也显示了master不在当前(-b,c,d,e)的变化。我希望看到这些更改不在master中,也就是我想看到c,d和e。
我试过使用 triple-dot 表示法或使用 git log ,但是这些与提示(最后提交)比较:
git diff master ...
git diff master ... current_branch
git log -p --no -merges current..master
返回c和d,即它们不包含e:工作树。
如何得到这个差异来包含工作树?
这里要记住的关键点是,如果两个分支共享提交X ,那么不会为diff添加任何内容,也就是说,您没有看到任何有关在diff *中提交X.
因此,您只需要根据分支点进行比较(可以通过 merge- )和$ diff: 返回c,d和e。 这也适用如果故事是针对那些看起来更复杂的(有几个合并)的话: 返回d和e。 *这解释了为什么您在 我敢打赌,现在要求你感到很傻! I am trying to find the diff between the current working tree and another branch (e.g. master) not including the merge commits. Now, I've tried using the triple-dot notation or using git log, but these compare against the tip (last commit): returns c and d, i.e. they don't include e: the working tree. How can I get this diff to include the working tree? The key point to remember here is that if both branches share commit X then this adds nothing to the diff, that is, you don't see anything about commit X in the diff*. Therefore you only need to diff against the branching point (which you can find with merge-base) and diff against that: returns c, d and e. This also works if the story is for those which are seemingly more complex (with several merges): returns d and e. * This explains why you don't see I bet you feel silly for asking now! 这篇关于Git diff分支针对不包含合并的工作树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ g $ diff $ git merge-base current master
。 --a - > 。 --b - > 。 ---。 (主)
\\ /
c \(合并)/(合并)
\\ /
。 -----。 -----。 --D - > 。 (当前) - e - > (工作树)
git diff master
中看不到 a
。
. --a--> . --b--> . (master)
\ \
c \ (merge)
\ \
. ----- . --d--> . (current) --e--> (working tree)
git diff master
does show the working tree changes, however it also shows changes in master not in current (-b, c, d, e). I want to see these changes not in master, that is, I want to see c, d and e.git diff master...
git diff master...current_branch
git log -p --no-merges current..master
git diff $(git merge-base current master)
. --a--> . --b--> . --- . (master)
\ \ /
c \ (merge) / (merge)
\ \ /
. ----- . ----- . --d--> . (current) --e--> (working tree)
a
in git diff master
.