I just got pretty strange result that I can’t explain
I wanted to determine difference between two branches
So i typed
git log master..release1
And I’ve got multiple commits, including let’s say aa11bb22cc33
But then I called
git branch --contains aa11bb22cc33
And I’ve got
release1
* master
How could this happen?!
My git log command by definition should show only those commits that are reachable in release1, but not reachable in master?
I also tried equivalent
git log ^master release1
with the same strange result.
Please explain if you can how is that possible.
P.S. git 1.8.0
Looking through a few man pages, I think it’s something like this: Even though
man gitrevisionssays that<A>..<B>is “anything reachable from B but not reachable from A”, just like you quoted, this “reachable” is meant in a strict DAG (directed acyclic graph) sense (i.e. “reachable from” means “is ancestor of”).Indeed the
git logmanpage states that<A>..<B>“shows only commits between the two commits.” The latter also concurs with how the dotdot operator was explained to me: “Everything in B that’s not also in A” (implying A and B are something like branches, which can “contain” commits).In the DAG-sense, however, there are no branches, only commits (any branches are only references to commits). So if commit X is “contained in B”, it is actually some ancestor of B, or in other words: it’s reachable from B — because in the Git history graph, every commit has relations (“pointers”, or arrows in a drawn graph) to its ancestor(s).
Hope this helps.
Edit: What I forgot to mention is why your commit shows up in the log but branch –contains shows both master and the other branch. I just thought I did know but turns out i don’t after all. If you post a the
git log --oneline --decorate --alloutput showing the concerned branches, I might be able to update my answer with a more concrete explanation 🙂