Why do so many people have trouble forming a mental picture of the Gita? The question eventually fell, in the context of a discussion following taking a stand programmer. This just pointed out the “counterintuitive” functioning of affiliates.
The interested party bases its presentation on the non-existence of the concept of “kinship” between branches. Therefore Git would not define them as human. In this case, in the manner shown opposite.
In Git, a branch is the complete history of all previous commits, she explains. Not just those in the shoot. So, hand AND branch office here each has four traditions, two of which are common.
Demo continued: In Git, branches are represented by text files that contain the identifier of their last commit. The reason this works is that each commit contains a pointer to its parent(s). However, the system does not know this branch office is an offshoot hand.
The “intuitive” design is therefore false… but still correct in a certain way, the developer continues. Proof: rebase and merge commands use it, like GitHub PRs. More precisely:
– Rebasing branch office on hand takes two traditions from the first and copies them into the second.
– Merge does not copy, but needs “basic” inclusion. Changes are examined from this point.
– On GitHub, if we make a PR for the merge branch office IN handtwo “intuitive branch” commits are shown.
In any case, Git doesn’t know that branch office is an offshoot hand, you have to tell it where to perform the operation. This ignorance of the concept of kinship means that it allows, for example, to perform “reverse basing”, which is counterintuitive at first glance.
Git branches, the story of pointers
This view of things is not unanimous, far from it. But the opposition is not unique either, at least in the discussion in question. However, participants generally agreed that branches are a form of pointer.
The Pro Git book, in audio chapter 3.1 (“Branch in a Nutshell”), asserts: “A Git branch is simply a lightweight, movable pointer to (commit)”. It takes the form of a simple file containing the 40-character SHA-1 fingerprint of the submission it points to. As validations progress, the branch “progresses” toward the last of the commits made.
Creating a new branch means creating a new pointer to the current commit. Git then knows which branch we are on thanks to a special pointer called HEAD.
The git checkout command, used to switch between branches, moves the HEAD pointer.
With each commit, the MAIN branch progresses. From there, the history of the project diverges.
Main illustration © Araki Illustrations – Adobe Stock