Thursday, July 26, 2012

SVN Switch

svn switch (sw) - update your working copy to a different URL.

Usage:
     svn switch <source> <dest>
or
     svn switch <source>
if the destination is your current location.

Examples:
Switching the entire working copy:
     svn switch http://examplesvn.com/svn/project/trunk
     svn sw http://examplesvn.com/svn/project/branches/branch_name

You can also choose to switch only a part/directory of your working copy:
     svn sw http://examplesvn.com/svn/project/branches/branch_name/subdir

Important!  When switching, always be in the directory that you want to switch; if you want to switch your entire working copy, then be in the top-level directory of your working copy.

Why switch?  It's convenient!  When working on multiple branches of your project, you don't need to checkout each branch to a different directory or location.  Also, since switch works like update, your local changes will also be preserved when you switch.

However, although this may be the case, I personally think it is better that you commit your local changes first before switching, because you'd want to avoid..

The S Status
Files with the S status (when you do a svn status) are from a different version - from a different location in your repository than the directory containing them.  This usually happens when svn switch gets interrupted in the middle, because it somehow gets confused from the local changes or conflicts.


As a final note, here are the things you'd want to think of first before switching:
  • svn info - check the URL your working copy is currently in
  • svn status (st) - check for local modifications, conflicts, or the S status
  • commit local changes first, to avoid conflicts and unexpected behaviors

No comments:

Post a Comment