SVN Merging Two Branches

Hill, Paul PHill at
Thu Nov 29 13:10:54 CST 2007

I am a "New User" as in:

"But which two trees should be compared? At first glance, the answer may
seem obvious: just
compare the latest trunk tree with your latest branch tree. But beware-this
assumption is wrong,
and has burned many a new user!"

I'm trying to get my head around this whole merging thing.

The above quote goes on to say

"Since svn merge operates like svn diff, comparing the
latest trunk and branch trees will not merely describe the set of changes
you made to your branch. Such a comparison shows too many changes: it would
not only show the addition of your branch changes, but also the removal  of
trunk changes that never happened on your branch."

It took me a while to come to any understanding of that last sentence.
Because of this, I might suggest some explanation of why I don't want both
branches changes.

"Since the trunk already has these changes, you don't need to include them
in this merge."

OK, one suggestion, now one typo question:

In order to find the complete list of changes for the branch, the book uses

$ cd calc/trunk
$ svn update
At revision 405.

Isn't this wrong in the case where the _branch_ has been updated later than
the trunk, because we want _all_ of the changes on the branch, and if the
_branch_ is up to 410 we don't want just from the base which is 341, through
405, we want 341 through 410.

Am I right?

Thus we need to ask about where the branch is:
$ cd branches/my-calc-branch
$ svn update
At revision 410
And then dropping back over to the target trunk we can attempt a merge
$ cd calc/trunk
$ svn update
At revision 405.
$ svn merge -r 341:410
Am I still right?

Also, could I not also do:

$ svn merge -r 341:HEAD

Give me some tough love on this and show me where my logic is pathetically


More information about the svnbook-dev mailing list