svn switch (sw)
Name
svn switch (sw) — Update working copy to a different URL.
Synopsis
svn switch URL[@PEGREV] [PATH]
svn switch --relocate FROM TO [PATH...]
Description
The first variant of this subcommand (without the
--relocate
option) updates your working
copy to point to a new URL. This is the Subversion way to
make a working copy begin tracking a new branch. If
specified, PEGREV
determines in
which revision the target is first looked up. See
the section called “Traversing Branches” for an in-depth
look at switching.
Beginning with Subversion 1.7, the svn
switch command will demand by default that the
URL to which you are switching your working copy shares
a common ancestry with item that the working copy
currently reflects. You can override this behavior by
specifying the --ignore-ancestry
option.
If --force
is used, unversioned
obstructing paths in the working copy do not automatically
cause a failure if the switch attempts to add the same
path. If the obstructing path is the same type (file or
directory) as the corresponding path in the repository, it
becomes versioned but its contents are left untouched in
the working copy. This means that an obstructing
directory's unversioned children may also obstruct and
become versioned. For files, any content differences
between the obstruction and the repository are treated
like a local modification to the working copy. All
properties from the repository are applied to the
obstructing path.
As with most subcommands, you can limit the scope of
the switch operation to a particular tree depth using the
--depth
option. Alternatively, you can
use the --set-depth
option to set a new
“sticky” working copy depth on the switch
target.
The --relocate
option is deprecated
as of Subversion 1.7. Use svn relocate
(described in svn relocate)
to perform working copy relocation instead.
Examples
If you're currently inside the directory
vendors
, which was branched to
vendors-with-fix
, and you'd like to
switch your working copy to that branch:
$ svn switch http://svn.red-bean.com/repos/branches/vendors-with-fix . U myproj/foo.txt U myproj/bar.txt U myproj/baz.c U myproj/qux.c Updated to revision 31.
To switch back, just provide the URL to the location in the repository from which you originally checked out your working copy:
$ svn switch http://svn.red-bean.com/repos/trunk/vendors . U myproj/foo.txt U myproj/bar.txt U myproj/baz.c U myproj/qux.c Updated to revision 31.
You can switch just part of your working copy to a branch if you don't want to switch your entire working copy, but this is not generally recommended. It's too easy to forget that you've done this and wind up accidentally making and committing changes both to the switched and unswitched portions of your tree.