33
votes

In subversion I made a branch now I want to merge it back into trunk. Which option should I use?

Reintegrate a branch

or

merge a range of revision

I was using Merge a range of revisions, but I was getting all sorts of tree conflict errors. Any idea what the difference is between these two?

3

3 Answers

37
votes

When working with a branch, you should periodically merge ranges of revisions from the trunk into the branch to keep the branch in sync. if you don't pass any version numbers to svn merge and your svn server version is 1.5 or newer, it will track the merges you've previously done and automatically merge only newer revisions.

When the branch is finished, you should merge changes into it one last time, then reintegrate it back into the trunk.

6
votes

Here are the steps I usually follow for merges.

1.

svn log -v --stop-on-copy http://mysvnrepo/mybranch

This will give you the repo revision when you first created the branch. Say it is AAAA.

2.

svn log -v -rAAAA:HEAD http://myrepo/trunk

This will give you the changes made in the trunk after you took out the branch. This is not essential but I use this to get an idea of what I should expect to merge presently.

3.

In case step2. reported trunk changes, go to the branch workspace and run

svn merge --dry-run -rAAAA:HEAD http://myrepo/trunk .

This will report all the changes made in trunk ever since you branched into mybranch - look through and re-run the command without the --dry-run option to perform the actual merge.

4.

Commit the branch workspace post-merge with a relevant comment. (for eg., "Merged changes from the trunk version AAAA through XXXX" - where XXXX is the current HEAD version)This brings up the HEAD to say version YYYY.

5.

Next in the trunk workspace, type

svn merge --dry-run -rAAAA:HEAD http://myrepo/branch .

This should report on the changes made in the branch after it was created up until now. Look through the report to verify what is getting merged/conflicted, etc., and then run the command without the --dry-run option, to actually perform the merge.

6.

Resolve conflicts if any by hand, run svn resolved to tell the repo that your conflicts are all now resolved, and then perform the commit with a relevant message, for example "Merging from mybranch to trunk - changes included from revision AAAA through YYYY". This helps the next time you run a log and then you can simply do the next merge from YYYY to the HEAD at that point.

4
votes

Tortoise SVN Merge vs Reintegrate explanation:

TortoiseSVN Documentation