Not able to think of a case where git diff master..lab and git diff master...lab would be different
git diff master..lab
It will produce the diff between the tips of the two branches.
git diff master...lab # not开发者_运维技巧ice triple dot
It will prouduce the diff starting from the common ancestor of the two branches.
I am not able to think of any scenario where the result from double dot would be different from result from triple dot.
I know you've seen this, but here's are the two snippets from the docs:
git diff [--options] <commit>..<commit> [--] [<path>...]
This is synonymous to the previous form. (
git diff [--options] <commit> <commit> [--] [<path>...]
)
git diff [--options] <commit>...<commit> [--] [<path>...]
This form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both .
git diff A...B
is equivalent togit diff $(git-merge-base A B) B
.
I can see how this might confuse you - the ..
and ...
notation for git diff don't mean the same thing as they do for revision listing (e.g. for git log).
So suppose our history looks like this:
A - B - C - D - E (master)
\
F - G (lab)
The first snippet tells us that git diff master..lab
is equivalent to git diff master lab
, in other words git diff E G
. This will tell us the direct differences between E
and G
- i.e. we'll see the combination of F
, G
, and the reverse patches of D
and E
.
On the other hand, git diff master...lab
is equivalent to git diff C G
- it shows the changes up to the second commit (lab) starting from the common ancestor of the two (the merge base of master and lab, which is C
). The diff we see will be the combination of F
and G
. It does not include D
and E
.
The use case for the triple dot notation is when you want to see all the work you've done on your topic branch (lab) that's not merged into master yet. You don't care what else has been done on master - you're only interested in the work you're doing on your topic branch.
精彩评论