Mercurial:我可以重命名分支吗?

发布于 2024-10-06 04:06:59 字数 64 浏览 0 评论 0原文

我们现在有一个“stiging”分支,其中“staging”似乎是一个更好的语义匹配。处理这个问题的好策略是什么?

We now have a "stiging" branch, where "staging" seems to be a far better semantic fit. What's a good strategy for handling this?

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

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

发布评论

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

评论(5

满意归宿 2024-10-13 04:06:59

更新到 stiging 分支并在其上创建一个新分支。然后关闭旧分支。

总之:

hg update stiging
hg branch staging
hg commit -m"Changing stiging branch to staging."
hg update stiging
hg commit --close-branch -m"This was a typo; use staging instead."
hg push --new-branch

Update to the stiging branch and create a new branch off of it. Then close the old branch.

In summary:

hg update stiging
hg branch staging
hg commit -m"Changing stiging branch to staging."
hg update stiging
hg commit --close-branch -m"This was a typo; use staging instead."
hg push --new-branch
匿名。 2024-10-13 04:06:59

对于未来的读者:使用 rebase 扩展,您可以创建一个与 stiging 具有相同父级的新分支,并将整个分支历史记录移至该分支,如下

hg update -r "parents(min(branch('stiging')))"
hg branch staging
hg commit
hg rebase --source "min(branch('stiging'))" --dest staging

所示 : stiging 只有一个父级。当然,您可以只使用明确的修订号。

注 1:如果分支 stiging 包含与其他分支的合并,我认为这将保留它们,只要 stagingstiging 有相同的父级。但我肯定会仔细检查。

注意 2:由于这会编辑历史记录,因此旧分支不会简单地从克隆存储库中消失(请参阅 rebase 文档)。除非每个人都可以重新克隆,否则对于大型团体来说这可能不是一个非常实用的解决方案。

Note3/编辑(@JasonRCoombs 提供):既然 阶段 是 Mercurial 中的标准,< code>rebase 将拒绝修改已经推送的变更集。要么通过将阶段更改回草稿(使用 hg Phases)来愚弄它,要么让旧分支保留在原来的位置,然后创建一个正确命名的副本(例如,使用 hg rebase --keep ')。

For future readers: With the rebase extension, you can make a new branch with the same parent as stiging and move the entire branch history to it, like this:

hg update -r "parents(min(branch('stiging')))"
hg branch staging
hg commit
hg rebase --source "min(branch('stiging'))" --dest staging

This assumes that stiging has only one parent. Of course you can just use explicit revision numbers instead.

Note 1: If branch stiging includes merges with other branches, I think that this will preserve them, as long as staging and stiging have the same parent. But I'd certainly double-check.

Note 2: Since this edits the history, the old branch won't simply disappear from cloned repositories (see the rebase documentation). Unless everyone can clone anew, it might not be a very practical solution for a large group.

Note3/Edit (courtesy of @JasonRCoombs): Now that phases are standard in mercurial, rebase will refuse to modify changesets that have already been pushed. Either fool it by changing the phase back to draft (with hg phases), or let the old branch stay where it is, and just make a properly named copy (e.g., with `hg rebase --keep').

江南烟雨〆相思醉 2024-10-13 04:06:59

创建一个名为“staging”的新分支并忘记其他......

Make a new branch called "staging" and forget the other...

绿光 2024-10-13 04:06:59

如果您有变更集,则必须使用 转换扩展一个分支图来重命名它。然后每个人都必须克隆新的存储库或剥离旧的分支。

If you have changesets on it, then you'll have to use the convert extension with a branchmap to rename it. Everyone will then have to clone the new repo or strip off the old branch.

煮酒 2024-10-13 04:06:59

这会修改历史记录,并且仅适用于高级 Mercurial 用户。如果您不知道这意味着什么,请不要这样做。

如果 stiging 仅是本地的,您可以将其更改为结合 graft 和条带。首先更新到 stiging 发生分歧的祖先变更集。创建暂存分支并将每个提交从暂存移植到暂存。登台现在应该是 stiging 的副本。最后,通过剥离其第一次提交来销毁 staging。

hg update {SHA-1 of the ancestor changeset}
hg branch staging
hg graft {first changeset in stiging} ... {stiging head-1} {stiging head}
hg strip {first changeset in stiging}
hg push --new-branch

This modifies the history and is only for advanced Mercurial users. Don't do this if you don't know what that means.

If stiging is local only, you can change it to staging with a combination of graft and strip. Start by updating to the ancestor changeset where stiging had diverged. Create the staging branch and graft each commit from stiging to staging. Staging should now be a copy of stiging. Lastly, destroy stiging by stripping its first commit.

hg update {SHA-1 of the ancestor changeset}
hg branch staging
hg graft {first changeset in stiging} ... {stiging head-1} {stiging head}
hg strip {first changeset in stiging}
hg push --new-branch
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文