In Mercurial, what's the difference between a head and a branch?

I am new to Mercurial and DVCS in general. What is the difference between a head and a branch?

+7
source share
4 answers

If you consider it like a tree, then the head is a leaf located at the very end of the branch.

He very well explained his own Mercurial wiki page:
Industries
Heads

+7
source

Answer: "It depends." Mercurial has four different branching strategies from which you can choose, and depending on how you choose to name the branch, the answer can be any: "they are not connected" to "they are one and the same."

First, consider four types of branching :

  • named branches
  • bookmarks as branches
  • anonymous branches
  • clones like branches

Click on the link if any of them is unclear to you.

Looking then at each of them, we will see how the head and branch are connected:

  • named branches are completely unconnected. you can have several chapters on one branch, and not every named branch should have a head
  • bookmarks as branches - mostly unrelated. bookmarks may point to heads or not heads, but they go to the "new head" when you commit
  • anonymous branches - chapters are branches in this model. They are unnamed and very light.
  • clones in the form of branches - branches - this , but you will most likely have them in separate repositories than in the same repo. You pull / push and then combine to one in this repo.

TL; DR: you need to understand both heads and branches in order to make good use of DVCS.

+5
source

From the wiki :

head set of changes that has no children

industry set of all change sets with the same branch name

Each set of changes refers to the default branch, if not specified.

If you are new and looking for a quick start, I recommend hginit.com .

+1
source

It is difficult to point out the differences because these are orthogonal concepts. They are explained in the Mercurial wiki, which has

0
source

All Articles