开发者

Merging between SVN branches

开发者 https://www.devze.com 2023-01-07 18:17 出处:网络
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 her

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 pe开发者_运维百科riodically from trunk into my branch, the merge going in the opposite direction would be trivial. Apparently not. What am I doing wrong?


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消