Mercurial:我可以重命名分支吗?
我们现在有一个“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
更新到
stiging
分支并在其上创建一个新分支。然后关闭旧分支。总之:
Update to the
stiging
branch and create a new branch off of it. Then close the old branch.In summary:
对于未来的读者:使用
rebase
扩展,您可以创建一个与stiging
具有相同父级的新分支,并将整个分支历史记录移至该分支,如下所示 :
stiging
只有一个父级。当然,您可以只使用明确的修订号。注 1:如果分支
stiging
包含与其他分支的合并,我认为这将保留它们,只要staging
和stiging
有相同的父级。但我肯定会仔细检查。注意 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 asstiging
and move the entire branch history to it, like this: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 asstaging
andstiging
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 (withhg phases
), or let the old branch stay where it is, and just make a properly named copy (e.g., with `hg rebase --keep').创建一个名为“staging”的新分支并忘记其他......
Make a new branch called "staging" and forget the other...
如果您有变更集,则必须使用 转换扩展一个分支图来重命名它。然后每个人都必须克隆新的存储库或剥离旧的分支。
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.
这会修改历史记录,并且仅适用于高级 Mercurial 用户。如果您不知道这意味着什么,请不要这样做。
如果 stiging 仅是本地的,您可以将其更改为结合 graft 和条带。首先更新到 stiging 发生分歧的祖先变更集。创建暂存分支并将每个提交从暂存移植到暂存。登台现在应该是 stiging 的副本。最后,通过剥离其第一次提交来销毁 staging。
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.