开发者

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

I'm new to Mercurial, and开发者_JS百科 DVCS in general. What's the difference between a head and a branch?


If you view it as a tree, then a head is a leaf, at the very end of a branch.

It's explained really well at Mercurial's own wiki:
Branches
Heads


The answer is "it depends". Mercurial has four different branching strategies from which you can pick, and depending how what you're choosing to call a branch the answer can be anything from "they're unrelated" to "they're the same thing".

First look at the four types of branching:

  1. named branches
  2. bookmarks as branches
  3. anonymous branches
  4. clones as branches

Hit the link if any of those are unclear to you.

Looking then at each of those let's see how a head and a branch are related:

  1. named branches - completely unrelated. you can have multiple heads per named branch, and not every named branch needs to have a head
  2. bookmarks as branches - mostly unrelated. bookmarks can point to heads or non heads, but they move to the "new head" when you commit
  3. anonymous branches - heads are branches in this model. They're unnamed and very light.
  4. clones as branches - heads are branches, but you're more likely to have them in separate repos than in the same repo. You pull/push and then merge down to one in that repo.

TL;DR: You need to understand both heads and branches to use a DVCS well.


From the wiki:

head a changeset that has no children

branch the set of all changesets with the same branch name

Every changeset belongs to a branch, default if not specified.

If you're new and looking for a quickstart, I recommend hginit.com.


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

  • an entry for Head and one for
  • one for Branch.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜