1

I would like to know I couple of things that Google couldn't tell me about SVN.

We at our work use SVN and the recommended trunk/branches/tags structure.

What I would like to know, is it necessary to switch the trunk folder to the branches/my branch folder, or can I work in the branches/my branch folder and commit those changes? I am speaking of physical folders here and the correct location to make the changes.

We haven't really needed to create a branch until now, and want to get it right :)

Thanks!

m.t.bennett
  • 1,290
  • 16
  • 34
  • Hm. Did you check The Book? :) Your question is covered in the SVNBook. I strongly advise you to check the following article describing the concept behind branching: http://svnbook.red-bean.com/en/1.7/svn.branchmerge.whatis.html – bahrep Jul 13 '12 at 13:31
  • I understand completely the concept of branching, however what I am interested in the working copies themselves. – m.t.bennett Jul 16 '12 at 02:28

3 Answers3

0

Switching isn't a good idea here. Basically, the command is used for relocating a project.

If you have a branch, then that branch has it's own life. Your trunk might be ahead in terms of committed functionality, or, it may come to be the other way around -- some branch will at some point be ahead of your trunk. If you use the switch command in the context you mentioned, you will end up in a mess and will eventually have to get a clean checkout.

If you're working with different branches, you need to understand and accept that each branch can be viewed as a separate trunk (based on another one). Therefore, have separate clean checkouts for the different branches you're working on

carlspring
  • 31,231
  • 29
  • 115
  • 197
0

I think the best first step is to match up Subversion's nomenclature and concepts with your own, otherwise I think you'll tie yourself in knots. For instance "switch the trunk to the branch" doesn't make sense. I suspect what you mean here is actually: "switch my working copy that currently contains the code for the trunk so that it contains code for the branch instead".

The repository stores the current state of the trunk and of any branches that have been created. Typically you would create a branch when you want to go back to fix bugs in an earlier release (eg for a 1.0.1 release) while you've made more substantial changes on the trunk for version 2.0 that would be too risky to put in 1.0.1.

When you work on a project you check out a working copy from either the trunk or a branch. Any commits you make will end up on the trunk or the branch you've checked out. If you need to work on the 1.0.1 branch you have two choices:

  • Check out a new working copy for this branch. Any commits get pushed onto that branch
  • Switch the working copy that you were using for the trunk so that it now follows the branch rather than the trunk. Any commits now get pushed onto the correct branch.

Which one of these two approaches you take will depend on a number of factors:

  • Do you have changes in the working copy that you haven't yet committed. If so then the simplest thing is to check out a new working copy. If you want to switch then you risk losing them, so either commit then or create a patch and put it aside
  • Is it expensive to create a new working copy? eg it might be a very slow network, a huge source tree, or take many hours to build. If so then you might prefer switching
  • Do your projects rely on hardcoded paths? If your build scripts assume that everything is in c:\source then that means that you can only have one working copy and you'll have to use switching.

For simplicity though I would recommend creating a new working copy for the branch.

the_mandrill
  • 29,792
  • 6
  • 64
  • 93
0

Create a branch from the trunk. Work in your branch making as many commits as you need. Once you've finished, merge any new commits from trunk to your branch, resolving any conflicts. Once all conflicts, if any, are resolved and you've tested your code, you can then merge your branch to trunk.

Stacey Richards
  • 6,536
  • 7
  • 38
  • 40
  • So specifically with the physical working locations, in the branches folder (branches/my_branch/files) am I able to work on this as i normally would the trunk? – m.t.bennett Jul 13 '12 at 12:00
  • Answer to your comment is yes. SVN doesn't really care about the folder and the names. They are just suggestions, no special meaning in "trunk" or "branch". They could really be "box" and "fiddle" – userfuser Jul 28 '16 at 11:38