将本地提交重新分配给Mercurial中的其他分支 [英] Reassigning local commits to a different branch in 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
是我创建的书签.标记为bmark
的newf
中的所有内容都是我的机器本地的.
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/
也就是说,列出了H
,I
和K
仍然属于newf
和bmark
,它们在属于分支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屋!