通过克隆进行分支 - 我必须在默认情况下进行修改才能看到分支吗?

发布于 2024-10-07 06:21:30 字数 835 浏览 0 评论 0原文

我来自 CVS 背景。

我尝试通过克隆来执行分支。

当前的默认树类似于 hello 项目。 alt text


  1. 我尝试将项目从“hello”克隆到“hello-branch-by-clone”。
  2. 我对“hello-branch-by-clone”进行了修改并提交。
  3. 我没有对“hello”做任何修改。
  4. 我执行从“hello-branch-by-clone”到“hello”的推送。

alt text

我希望看到一个分支,但我没有。


这次,我尝试另一种方法。

  1. 我对“hello-branch-by-clone”进行了修改并提交。
  2. 我对“hello”进行了修改并提交。
  3. 我需要从“hello”拉取“hello-branch-by-clone”,然后合并。
  4. 我执行从“hello-branch-by-clone”到“hello”的推送。

这次,只有我可以看到分支 alt text


通过应用克隆技术,有什么办法可以拥有分支视图,而无需显式修改默认存储库 (hello)

I am coming from CVS background.

I try to perform branch by cloning.

The current default tree looks like this from hello project.
alt text


  1. I try to clone a project out from 'hello' to 'hello-branch-by-clone'.
  2. I did modification on 'hello-branch-by-clone' and commit.
  3. I did not do any modification on 'hello'.
  4. I perform push from 'hello-branch-by-clone' to 'hello'.

alt text

I expect to see a branch but I didn't.


This time, I try another way around.

  1. I did modification on 'hello-branch-by-clone' and commit.
  2. I did modification on 'hello' and commit.
  3. I need to pull from 'hello' to 'hello-branch-by-clone', and merge.
  4. I perform push from 'hello-branch-by-clone' to 'hello'.

This time, then only I can see the branch
alt text


By applying cloning technique, is there any way I can have a branch view, without having explicitly modify the default repository (hello)

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

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

发布评论

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

评论(1

星星的轨迹 2024-10-14 06:21:30

没有分叉,因为没有两个变更集共享父级。

克隆存储库在任何方面都没有什么特殊之处。它与原始版本相同。对它的提交与原始存储库中的提交相同。理论上它们并没有被标记为在分支上。克隆只是拥有另一个工作区域的好方法,您可以在不影响原始工作区域的情况下执行一些工作(包括提交)。

当两个或多个提交具有相同的父级时,就会发生分叉。使用克隆时经常会发生这种情况,但也可能不会。如果只有一个变更集具有相同的父级,则不会出现分叉。

在第一个序列之后,您只引入了一个变更集 (4),该变更集将旧提示 (3) 作为其父级,因此它仍然是一条直线。只有当您引入以 (3) 为父级的第二个变更集时,您才会看到分叉。

现在请记住,即使您“推送”了变更集,并且原始“Hello”存储库包含所有 4 个变更集,但它的工作目录仍然指向变更集 (3)。它将保持这种状态,直到您在其中运行“hg update”为止。这意味着如果您要在“Hello”中进行提交,它将基于(3),然后会出现一个分叉。何时进行此提交并不重要。

这就是您在第二个序列中所做的事情。

希望有帮助。


我尝试在其中使用术语“fork”,因为“branch”有很多含义,包括“hgbranch”命令,它执行一些略有不同的操作。

There's no fork because no two changesets share a parent.

A cloned repository isn't special in any way. It's identical to the original. Commits to it are identical to commits in the original repo. They aren't notionally tagged as being on a branch. A clone is just a nice way of having another work area that you can do some work (including commits) without effecting the original.

A fork occurs when two or more commits have the same parent. Often this happens when using clones, but it may not. If there's only one changeset with the same parent, there is no fork.

After your first sequence you've introduced just one changeset (4) which is which has the old tip (3) as it's parent, so it's still a straight line. Only when you introduce a second changeset parented by (3) will you see a fork.

Now remember, even though you 'push'ed the changeset back, and the original "Hello" repo contains all 4 changesets, it's working directory is still pointing to changeset (3). It will stay that way until you run 'hg update' inside it. This means that if you were to make a commit in "Hello" it will be based upon (3), and then a fork will appear. It doesn't matter when this commit is made.

This is what you did in your second sequence.

Hope that helps.


I've tried to use the term 'fork' in this, because 'branch' has lots of meanings, including the 'hg branch' command which does some slightly different things.

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