Apache Subversion’s ‘svn switch’ command allows users to update a working copy to a different URL. This is useful when you need to update your working copy to mirror a newly-created branch.
Although it’s possible to achieve the same effect by performing a fresh checkout, the ‘svn switch’ command is a quicker alternative. It saves you the overhead of running ‘svn checkout,’ and applies the changes required to bring your working copy inline with the new location, making it a very efficient command. It also preserves any changes you’ve made in the working copy.
To perform a switch, run ‘svn switch’ followed by the URL path you wish to mirror. Apache Subversion will then go ahead and update your working copy.
There are some additional options you can apply to fine-tune the ‘svn switch’ command:
- Ignore Ancestry
If Subversion cannot find a common ancestor for the URL and your working copy, it will block the operation and display an error message.
It is possible to force Subversion to switch to this URL anyway, by adding the –ignore-ancestry option.
svn switch (target-URL) –ignore-ancestry
- Target a Particular Revision
You can also specify a particular revision of the URL you’re switching to. Note that Subversion defaults to the HEAD revision, if no alternate revision is specified:
svn switch -r(revision-number) (target-URL)