在 Mercurial 中,“头部”和“头部”之间有什么区别?和一个“分支”?

发布于 2024-11-10 09:20:29 字数 60 浏览 2 评论 0原文

我是 Mercurial 和 DVCS 的新手。 分支有什么区别?

I'm new to Mercurial, and DVCS in general. What's the difference between a head and a branch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

杀手六號 2024-11-17 09:20:29

如果你把它看作一棵树,那么头就是一片叶子,位于树枝的最末端。

Mercurial 自己的 wiki 对此进行了很好的解释:
分支机构

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

锦上情书 2024-11-17 09:20:29

答案是“这取决于”。 Mercurial 有四种不同的分支策略可供您选择,并且根据您选择的分支名称,答案可以是从“它们不相关”到“它们是同一件事”的任何内容。

首先看一下四种类型的分支

  1. 命名分支
  2. 书签作为分支
  3. 匿名分支
  4. 克隆作为分支

如果您不清楚其中任何一个,请点击链接。

然后,让我们看看每一个分支是如何相关的:

  1. 命名分支 - 完全不相关。每个命名分支可以有多个头,并且并非每个命名分支都需要有一个头
  2. 书签作为分支 - 大多不相关。书签可以指向头或非头,但当您提交
  3. 匿名分支时,它们会移动到“新头” - 在此模型中,头分支。它们没有名字,而且很轻。
  4. 克隆作为分支 - 头分支,但您更有可能将它们放在单独的存储库中,而不是放在同一存储库中。您拉/推,然后合并到该存储库中的一个。

TL;DR:您需要了解头和分支才能很好地使用 DVCS。

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.

甜柠檬 2024-11-17 09:20:29

来自 wiki

head一个没有子项的变更集

分支具有相同分支名称的所有变更集的集合

每个变更集都属于一个分支,如果未指定,默认

如果您是新手并且正在寻找快速入门,我建议您访问 hginit.com

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.

初熏 2024-11-17 09:20:29

很难指出差异,因为这些是正交的概念。它们在 Mercurial wiki 中进行了解释,其中有

  • 一个 Head 的条目,以及一对一的
  • 分支

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文