One of the biggest surprises for me while learning Git was the fact that revisions are not permanently associated with a specific branch; rather, a branch merely points to a particular revision. Once I've fully internalised this concept, I realised that I don't understand how to actually use this feature properly.
I've read the apparently famous essay about a successful Git branching model, which depicts the branches as lines, and revisions as being clearly associated with one line. Consider this excerpt:
This shows two feature branches (call them featureA
and featureB
), and a develop
branch. Moreover, featureB
was fully merged into develop
and then briefly diverged again, only to be re-merged.
This looks nice, tidy and understandable, and also happens to be what the repo would literally look like at the end of this process in something like Mercurial. I understand this much, I like it, and I'd like to develop like this (and I did, in Mercurial). However, in Git, the final state doesn't look like that. It looks like this:
In other words, the only information we have about the two feature branches is that they are now at the same revision as the develop branch. As a result, the best we can infer for the whole tree is this:
In other words, all that nice information about the history of how the development occurred is lost; it was never recorded in the first place. Observe how in the first graph, three revisions are clearly on featureB
before they were merged into develop
, but I don't see how we can know that those three revisions were on featureB
before the merge.
Is this correct? Is the above the best I can recover after-the-fact in Git, and is the screenshot from the essay therefore rather misleading? Or is there something important I'm missing?