问题描述
假设我有一个名为"B1"的分支,正在进行功能开发.尽管还没有完成该功能,但在演示之前我处于一个很好的停顿点,所以我:
Let's say that I have a named branch 'B1' which I'm doing feature development on.I am at a good stopping point before a demo though not done with the feature so I:
hg up default
hg merge B1
hg ci -m "merged in feature drop"
hg push
现在我继续工作了一个半小时左右,然后继续进行提交,只是意识到我忘记了更新回B1并且我当前的工作目录在default
上-uhoh.从理论上讲,我应该能够将我的工作目录父级标记为B1的提示-有简单的方法吗?
Now I continue working for a half an hour or so and go to commit only to realize that I forgot to update back to B1 and that my current working directory is on default
- uhoh. In theory I should be able to just mark my working directory parent as the tip of B1 - is there an easy way to do this?
我当然可以提交,更新回B1并合并回我的更改,但是默认情况下有一个不稳定的更改集,这种情况经常发生在我身上,我想找到一个真正的解决方案.
I could of course commit, update back to B1, and merge my changes back, but then there's an unstable changeset in default and this happens often enough to me that I would like a real solution.
推荐答案
两种方式.首先,显而易见的方法:
Two ways. First, the obvious way:
hg diff > foo
hg up -C b1
hg import --no-commit foo
rm foo
第二,神奇的方式:
hg up -r 'ancestor(., b1)' # take working dir back to the fork point
hg up b1 # take it forward to the branch head
这种方式涉及合并.根据分支的差异程度,这可能会很轻松.否则可能会很复杂,并且可能使您没有保存到任何地方的更改变得一团糟.这就是为什么甚至像我这样的魔术师也更喜欢采用第一种方法的原因.
This way involves merges. Depending on how much your branches have diverged, this may be painless. Or it may be complicated, and you may make a mess of your changes that you haven't saved anywhere. Which is why even magicians like myself prefer to do it the first way.
这篇关于Mercurial:在不丢失更改的情况下将工作目录切换到分支吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!