SVN Merge – Branch into Trunk

So you are working on this humongous project and its that time when everyone in the team

has to start working on different modules or functionalities. The way to proceed is to create

module branches and start working on it.

Sooner than you may think, you would be required to merge all those branches into the trunk

once you have your module complete and tested.

Enough of background, lets go ahead and merge those branches..

Your svn trunk directory:

Your svn branch directory:

So we start with the trunk

svn co

To create a branch from trunk we use svn cp

svn cp

Simultaneously we work on the branch as well

svn co

Now when we need to merge the branch into the trunk,we first check the revision

at which the branch got created.We do that as following:

svn log --stop-on-copy

Keep a note of the revision number where the branch got created.Lets call it rev AAAA

Now switch the working directory of the branch to trunk using

svn switch

Post switch, update your directory

svn up

Keep a note of revision it gets updated to. Lets call it rev BBBB

Now the important task of merging the branch.

svn merge -rAAAA:BBBB

Resolve the conflicts and commit ..

svn ci -m 'Merged branch mybranch into trunk'

Voila! We are done! Happy Merging!!!

5 thoughts on “SVN Merge – Branch into Trunk

  1. Thanks a lot !!
    After merging branch into trunk,
    can we switch working copy back to branch so that we can continue with the branch development?

  2. One point to note while merging multiple revisions is that the start revision is excluded i.e.

    given start=AAAA, end=DDDD
    the merge will include AAAA+1 upto DDDD (where DDDD is included)

Leave a Reply to Zee Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s