HG的分支如何开发?

发布于 2024-08-30 05:07:51 字数 373 浏览 5 评论 0原文

我想在 hg 项目中做一些实验工作。所以我想创建分支并提交它。如果实验有效,我可以将其合并回主分支。

在 git 中,我可以

$ git branch experimental
$ git checkout experimental
(edit file)
$ git commit -a
$ git checkout master

阅读 指南到 Mercurial 中的分支。它说hg分支功能。但下一步是什么? 我不跟。

I would like to do some experimental work in a hg project. So I would like to create branch, commit to it. And if the experiment works, I can merge it back to main branch.

In git, I can do

$ git branch experimental
$ git checkout experimental
(edit file)
$ git commit -a
$ git checkout master

I've read A Guide to Branching in Mercurial. It said hg branch feature. But what is next?
I don't follow.

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

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

发布评论

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

评论(3

国际总奸 2024-09-06 05:07:51
$ hg branch experimental

(edit file)
$ hg commit
$ hg update default
$ hg branch experimental

(edit file)
$ hg commit
$ hg update default
阿楠 2024-09-06 05:07:51

首先请注意,gitbranchhg 分支。使用 hgbranch 创建的分支是永久的,并且存在于全局名称空间中,而使用 gitbranch 创建的分支是暂时的。与 gitbranch 最接近的等效项是 hg bookmark:书签可以重命名和删除,其行为更像 Git 分支。

我最近编写了Mercurial 书签指南。将此与命名分支指南进行比较。两个指南都包含如何在 Mercurial 中使用(命名)分支来跟踪开发的工作示例。它展示了如何合并分支以及如何在完成后关闭它们或删除书签。

First note that git branch is different from hg branch. Branches created with hg branch are permanent and live in a global name space, whereas branches made with git branch are transient. The nearest equivalent of git branch is hg bookmark: bookmarks can be renamed and deleted and behave more like Git-branches.

I've recently written a guide for Mercurial bookmarks. Compare this with the named branch guide. Both guides contain worked examples of how to use (named) branches in Mercurial for keeping track of the development. It shows how to merge branches and how to close them or delete the bookmark when you are done.

回忆那么伤 2024-09-06 05:07:51

如果它不是一个大功能(即分支不必有名称),那么它非常简单。

假设您的存储库位于变更集 X。您可以按照自己喜欢的方式处理该功能,提交,提交,提交,如果您对结果感到满意,请继续,就好像您知道它会一直工作一样。 ;) 如果您不满意,请执行 hg update X 并从那里继续开发。您在实验中所做的所有工作都将成为匿名分支。

奇怪的是,它出现 Git 没有提供这样一种处理匿名分支的方法,这可能会让您感到困惑。

If it's not a big feature (i.e. the branch doesn't have to have a name), it's quite simple.

Let's say your repository is at changeset X. You work on the feature as much as you like, commit, commit, commit and if you're happy with the result, continue as if you knew it would work all along. ;) If you aren't happy, do a hg update X and continue development from there. All the work you did on your experiment will become an anonymous branch.

Strangely enough, it appears that Git doesn't provide such a way to work with anonymous branches which is what might be confusing you.

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