Cuelogic Blog Icon
Cuelogic Career Icon
Home > Blog > Product Development > SVN MERGE TRUNK CHANGES TO YOUR BRANCH

SVN MERGE TRUNK CHANGES TO YOUR BRANCH

SVN MERGE TRUNK CHANGES TO YOUR BRANCH

Very often we create separate branches for new feature or for issues, so that we can work on it without affecting the mainstream code i.e. trunk. As we are working on feature our trunk may get modified with changes merged from other braches or code modified in the trunk itself e.g. important bug fixes. Is is possible to have all these changes in our working branch? The answer is “YES”. Keeping branch updated with trunk changes also helps us minizing the risk of code conflicts while mergin branch into trunk

How to merge trunk changes into your branch?

On your branch, get the revision number when it was created:

svn log

Lets say branch was created at r3310

Now find out what revision number the trunk is at

svn update
At revision 3316.

It shows that trunk is at revision:

r3316

Now lets merge trunk changes into our branch with “svn merge” command:

svn merge -r 3310:3316 svn+ssh://username@svnserver/home/username/svn/project/trunk

This will merge the trunk changes into your branch, changes from the revision 3310 (i.e. when branch was created) to revision 3316 i.e. most updated revision
If any conflict occurs, handle it. If everything is fine we can safely commit the changes into our branch with svn commit

svn ci -m "Merged trunk changes -r 3310:3316 into my branch"