SVN分支之间的合并
我已经在 SVN 分支中开发一个功能一段时间了。我定期将主干中的更改合并到我的私有分支中,以便我可以使用描述的过程获取其他人的更改 这里。这看起来效果很好。
现在我准备将我的更改合并到主干中。我试图通过合并从我分支点开始并以分支 HEAD 结束的修订范围来做到这一点。但是当我尝试这样做时,SVN 报告了许多树冲突。看起来添加到主干(并合并到我的分支)中的每个文件都存在冲突。
我希望通过定期从主干合并到我的分支中,相反方向的合并将是微不足道的。显然不是。我做错了什么?
I've been working on a feature in an SVN branch for a while. Periodically, I merged changes from trunk into my private branch so I could get everyone else's changes using the procedure described here. That seemed to work fine.
Now I'm ready to merge my changes into trunk. I'm trying to do this by merging the range of revisions starting from the point I branched and ending with HEAD of the branch. But when I try to do this, SVN reports numerous tree conflicts. It looks like every file that was added in trunk (and merged into my branch) is in conflict.
I was hoping that by merging periodically from trunk into my branch, the merge going in the opposite direction would be trivial. Apparently not. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要重新集成分支。
另外,当您将主干合并回分支时,您应该与祖先合并,否则 SVN 不知道合并了哪些修订。
You need to re-integrate the branch.
Also, when you merge the trunk back into your branch, you should have merged with ancestory otherwise SVN doesn't know what revisions have been merged.
您需要将分支重新集成到主干中。从清理主干开始,然后您应该将分支合并(或重新集成,如果您使用 TortoiseSVN)到主干。
合并期间很可能会出现一些冲突。有冲突并不代表有问题。只需在提交回主干之前解决这些问题即可。
另外,您/服务器/存储库可能正在使用旧版本的 SVN(1.5 之前),该版本没有合并跟踪。这可能是大量冲突的根源,因为 SVN 不会知道您合并到分支中的所有修订,并且会尝试再次将这些修订中的更改合并到主干中。合并跟踪可帮助 SVN 忽略主干中已对分支进行的更改。
You need to re-integrate the branch into the trunk. Start with a clean checkout of the trunk and then you should merge (or reintegrate if you are using TortoiseSVN) the branch into the trunk.
It is quite probable that you will have a few conflicts during the merge. Having conflicts does not mean there is a problem. Just resolve these before committing back to the trunk.
Also, it could be that you/server/repository are using an old version of SVN (pre 1.5) that did not have merge tracking. This could be the source of loads of conflicts because SVN wouldn't know about all the revisions you merged into your branch and would try to merge changes from those revisions into the trunk for a second time. Merge tracking helps SVN to ignore changes to your branch that are already made in the trunk.
假设您正在使用某些支持合并跟踪的 Subversion 版本(v1.5 或更高版本),那么您需要的魔法就是“重新集成合并”。
SVN 中有几种不同类型的合并,“重新集成合并”与您为使分支保持最新而执行的“增量合并”不同。简而言之,增量合并(这是默认的合并类型)会逐个修订地带来更改。如果您在返回主干时尝试其中一种合并,那么您将把在分支中所做的所有更改带回主干,以及源自主干并带入分支的所有更改。这就是为什么你会看到冲突。
SVN 书很好地解释了这一点;阅读本节 仔细地更好地处理这个问题。
Assuming you are using some version of Subversion that support merge tracking (v1.5 or higher), the magic you need is a "re-integrate merge".
There are a few different kinds of merges in SVN, and a "re-integrate merge" is different from the "incremental merges" you've been performing to keep your branch up to date. In short, an incremental merge (which is the default kind of merge) brings across changes on a revision-by-revision basis. If you try one of these merges when going back into trunk, you'll be bringing back into trunk both changes that you have made in the branch, PLUS all of the changes that originated in trunk that were brought into your branch. That's why you are seeing conflicts.
The SVN book explains this pretty well; read this section carefully to get a better handle on this.