我试图弄清楚如何将分支从一个单独的仓库合并到当前仓库。
我有以下内容:
PJT1
-包含默认的分支和foodog
PJT2
-包含分支默认
从PJT2,我执行以下操作:
$ hg fetch -y ../PJT1 -r foodog -m "this is a test"
现在,如果我查看PJT2,我会看到正确的文件和更改。但是,如果我执行
hg branches
,则会得到以下信息:[someone@myhome pjt2]$ hg branches
foodog 1:c1e14fde816b
default 0:7b1adb938f71 (inactive)
hg branch
显示以下内容:[someone@myhome pjt2]$ hg branch
foodog
如何从PJT1的
foodog
分支获取内容到PJT2的default
分支?
最佳答案
您需要合并,但是请记住,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
合并后,除非您执行
hg branches
(仅显示带有头的分支),否则foodog
仍将显示hg branches --active
。在commit --close-branch
之后,除非您执行foodog
,否则您将看不到hg branches --closed
。因为Mercurial中的分支永远不会完全消失(一种设计功能),所以它们通常仅保留给诸如
release-1.0
或stable
之类的终身使用。对于漏洞和功能之类的短暂工作,请考虑使用书签。这是两者的绝佳对比:http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial
关于mercurial - merge 来自不同存储库的Mercurial分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5186976/