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:
Lets say branch was created at r3310
Now find out what revision number the trunk is at
At revision 3316.
It shows that trunk is at revision:
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"