下一个: Merging more than once, 上一个: Magic branch numbers, 上层: Branching and merging
你可以把另一个分支上的修改合并到你的工作副本,只要在 update 子命令中加
`-j branchname' 的标志。使用一个 `-j branchname' 选项,
它把在分支的最大公共祖先(GCA)和目的修订版之间所做的改变(在下面简单的情况下 GCA
是分支在那里分岔的点)和在那个分支上的最新修订版合并进你的工作副本。
+-----+ +-----+ +-----+ +-----+
! 1.1 !----! 1.2 !----! 1.3 !----! 1.4 ! <- The main trunk
+-----+ +-----+ +-----+ +-----+
!
!
! +---------+ +---------+
Branch R1fix -> +---! 1.2.2.1 !----! 1.2.2.2 !
+---------+ +---------+
分支 1.2.2 分配了一个 `R1fix' 的标签(符号名)。下面的例子假定模块 `mod' 只包含一个文件 m.c。
$ cvs checkout mod # Retrieve the latest revision, 1.4 $ cvs update -j R1fix m.c # Merge all changes made on the branch, # i.e. the changes between revision 1.2 # and 1.2.2.2, into your working copy # of the file. $ cvs commit -m "Included R1fix" # Create revision 1.5.
在合并时可能会发生冲突。如果这种情况发生,你应该在提交新版本之前解决它。 参阅 Conflicts example.
如果你的原文件中包含关键字(参阅 Keyword substitution),你可能会得到比严格 意义上的冲突更多的冲突信息。见 Merging and keywords,去了解如何避免这个问题。
checkout 命令也支持使用 `-j branchname' 标志。下面的例子同上面
所用的例子有相的效果:
$ cvs checkout -j R1fix mod
$ cvs commit -m "Included R1fix"
注意使用 update -j tagname 也许行但结果可能不是你想要的。详见
参阅 Merging adds and removals.