eclipse 如何正确合并2个分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7598316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to correctly merge 2 branches
提问by Gundon
I have a master-branch called trunkand a branch of it called prototypehas been created.
我有一个名为 master 的分支,trunk并且prototype已经创建了一个名为的分支。
Since the branch happened, commits have been done in both trunkand prototype(sometimes even the same files).
自从分支发生以来,提交已经在两个trunk和prototype(有时甚至是相同的文件)中完成。
What's the best way to update the prototype so that it contains all new commits from the trunk without losing the prototype-commits?
更新原型以使其包含来自主干的所有新提交而不会丢失原型提交的最佳方法是什么?
I just tried to rightclick on my projectfolder -> Team -> Merge, selected the trunkas From:and my prototypeas To:. I also checked both Merge from HEAD revision.
我只是尝试右键单击我的 projectfolder -> Team -> Merge,选择trunkas From:和我的prototypeas To:。我还检查了HEAD 修订版的 Merge。
But after this some new files of prototypewere missing.
但在此之后,一些新文件prototype丢失了。
采纳答案by JB Nizet
First of all, the merge must be done on the working copy of the prototype branch.
首先,必须在原型分支的工作副本上进行合并。
A merge consists in applying a diff between two versions of some branch to another branch. The Fromand the Tomust thus both point to the trunk. You want to apply, on the prototype branch, the changes made on trunk, from revision X to revision Y.
合并包括将某个分支的两个版本之间的差异应用到另一个分支。因此theFrom和 the Tomust 都指向主干。您想在原型分支上应用对主干所做的更改,从修订版 X 到修订版 Y。
This is very well explained in the SVN book.
这在SVN 书中有很好的解释。
回答by H-Man2
You should first update your branch to get the changes since you have branched
(this is easier if you do this frequently). How to achive this is answered here. In short: you do not specify the different subtrees of the repositories but a range of revisions, so the addresses of fromand toare most times the same.
您应该首先更新您的分支以获取分支后的更改(如果您经常这样做,这会更容易)。此处回答了如何实现这一点。简而言之:你不指定库的不同子树,但一个版本范围,这样的地址from,并to在大部分时间相同。
After the branch is working correctly with all new files from the trunk you should commit the branch and then merge the changes back to the trunk with the same mechanism. When the branch is closed after the integration into the trunk you should use "reintegrate a branch", but this will make the branch read only.
在分支与主干中的所有新文件正常工作后,您应该提交分支,然后使用相同的机制将更改合并回主干。当分支在集成到主干后关闭时,您应该使用“重新集成分支”,但这将使分支只读。

