tags:

views:

58

answers:

3

Hi,

If you have created a branch and are working with the files in that branch, when you 'update' it, is it updating/merging the code in the branch with the code in the trunk?

Also, when you have commited your changes to the branch, how do you update the trunk with your changes? (since you commit the changes and have to switch to the trunk again?)

Any comments will be appreciated :)

Thanks,

+2  A: 

When you update your working folder while working on a branch, you're updating with new changes in that branch, from the repository, not from the trunk.

So unless others are working in the branch with you, updating won't do anything.

To get your changes back into the trunk (or to get changes done to trunk into your branch), you need to use the merge operation.

You can read more about branching and merging in the subversion red-book under chapter 4. Branching and Merging.

Lasse V. Karlsen
Also prepare yourself for a fair bit of pain when merging branches, subversion can be a little flakey when you switch branches or merge.
Ceilingfish
Thanks for your reply and link :) when you use the merge option, is it as straight forward as updating the branch and fixing conflicts etc?
aspdotnetuser
Well, "straight forward", yes, it's those operations, you merge branch into trunk if you're done with the branch (or wish to do a semi-release of your changes), or merge from trunk into branch if you wish to get other changes into your branch (for instance if you're depending on a particular bugfix), but whether or not it is "straight forward" depends entirely on the number of conflicts you experience. Just make sure you don't have uncommited changes in your working copy, much easier to revert and try again if you mess up.
Lasse V. Karlsen
+1  A: 
  1. No. It is practically not possible to "update" branch from the trunk. Branch is not like a working copy. You could, theoretically, merge all changes from trunk to branch, but this will create problems when committing your changes back to trunk.

  2. This operation is called "reintegrate branch". It is actually a form of a merge. After that, the branch may be deleted.

Pavel Radzivilovsky
So basically, the branch can't be updated unless other people are working on the same branch and have made changes? I think I nearly understand svn / working with subversions now - but I'm not clear about the way in which the trunk is updated with the branch changes. Also, how do you coordinate things if there are lots of branches to add to the trunk?
aspdotnetuser
Merging a branch is just like a regular commit. It's okay for many people to work on the same set of files. During merge, you are going to have a nice display of changesets and merge them semi-automatically. The merge is first done on local copy, mapped to trunk. Then, after you compose the would-be new state of the trunk, you commit it by a regular commit.
Pavel Radzivilovsky
+2  A: 

First of all, in Subversion "branch" == "ordinary directory". You create directory "branches" in repository and say that it will contain branches, but Subversion doesn't distinguish this directory from any other. The same applies to "trunk", "tags", etc.

So, when you perform "update" on branch, you only update the directory.

As Lasse said, to get the changes into the trunk you should use "merge" operation.

Dmitry