将本地提交重新分配给Mercurial中的其他分支 [英] Reassigning local commits to a different branch in Mercurial

查看:97
本文介绍了将本地提交重新分配给Mercurial中的其他分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在回购中使用了hg书签,因为它们使我可以轻松地使用不同的功能. Mercurial的问题在于,所有提交仍与一个分支相关联.因此,我所做的是,我有很多本地更改,并且对同一分支进行了很多拉取(但没有更新的更改).换句话说,我的本地仓库看起来像这样:

I'm using hg bookmarks in my repo because they allow me to work with ease on different features. The thing with Mercurial is that, still, all commits are associated with a branch. So, what I did is that I have a lot of local changes, with a lot of pulled (but not updated changes) to the same branch. In other words, my local repo looks like this:

default     -------E-F---------
newf        -A-C-D---------J---
newf,bmark  --\--------H-I----K

newf是位于远程的分支,上拉到J,而bmark是我创建的书签.标记为bmarknewf中的所有内容都是我的机器本地的.

newf is a branch that is on remote, pulled up to J, and bmark is the bookmark I created. Everything in newf, marked with bmark is strictly local to my machine.

现在,我想将H,I和K(实际上有约20个更改)重新分配给另一个分支,我可以将其推送到存储库中.在Mercurial中有没有办法做到这一点,以使我的工作副本(我仍然有一些未提交的更改)保持尽可能不受影响?

Now, I would like to re-assign H, I, and K (actually, there are ~20 changes) to a different branch, which I can push to the repo. Is there a way to do it in Mercurial, so that my working copy (I still have some uncommitted changes) remains as unaffected as possible?

基于使用"rebase"的建议,我尝试了以下步骤:

Based on the suggestion to use 'rebase', I tried the following steps:

hg up -r A
hg branch newbranch && hg ci -m "will hold some development"
# This effectively made a commit X
hg up bmark
hg rebase -d newbranch

除了遇到一些关于阶段的错误外,rebase还给了我一些我不期望的东西:

Apart from getting some errors about phases, the rebase gives me something I would not expect:

default     -------E-F---------
newf        -A-C-D---------J---
newf,bmark    \   -----H-I----K
newbranch      \X/

也就是说,列出了HIK仍然属于newfbmark,它们在属于分支newbranch的提交X的顶部.我在这里做错什么了吗?

That is, H,I, and K are listed to still belong to newf and bmark, and they are on top on commit X that belongs to branch newbranch. Am I doing something wrong here?

推荐答案

我使用 rebase 来将提交从一个分支移动到另一个分支.这样适合您吗?

I use rebase to move commits from one branch to another. Would it work in your case?

这篇关于将本地提交重新分配给Mercurial中的其他分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆