合并来自不同存储库的Mercurial分支
收藏

我试图弄清楚如何将分支从一个单独的仓库合并到当前仓库。

我有以下内容:

PJT1 -包含默认的分支和foodog

PJT2 -包含分支默认

从PJT2,我执行以下操作:

$ hg fetch -y ../PJT1 -r foodog -m "this is a test"

Now, if I look in PJT2, I see the correct files and changes. However, I if I do hg branches, I get the following:

[someone@myhome pjt2]$ hg branches
foodog                         1:c1e14fde816b
default                        0:7b1adb938f71 (inactive)

and hg branch reveals the following:

[someone@myhome pjt2]$ hg branch
foodog

How do I get the contents from PJT1's foodog branch into PJT2's default branch?

最佳答案

您需要合并,但是请记住,foodog分支上的更改将始终在foodog上-分支永远不会消失,但是它们可以被隐藏。此命令序列与您要询问的内容非常接近:

cd PJT2
hg update default # just in case you were somewhere else
hg pull ../PJT1 -r foodog  # that gets you foodog
hg merge foodog  # that merges the changes into default
hg commit # commit the merge
hg update foodog # go to the most recent change in foodog (note: it is not a 'head')
hg commit --close-branch

After the merge hg branches will still show foodog unless you do hg branches --active which only shows branches that have heads on them. After the commit --close-branch you won't see foodog unless you do hg branches --closed.

It's because branches in Mercurial never go away entirely (a design feature) that they're often reserved only for life-long things like release-1.0 or stable. For short-lived efforts like bugs and features consider using bookmarks instead. Here's a great comparison of the two: http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial

    公众号
    关注公众号订阅更多技术干货!