<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>svn switch</title><link rel="stylesheet" href="styles.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><link rel="start" href="index.html" title="Version Control with Subversion" /><link rel="up" href="svn.ref.svn.html#svn.ref.svn.c" title="svn Subcommands" /><link rel="prev" href="svn.ref.svn.c.status.html" title="svn status" /><link rel="next" href="svn.ref.svn.c.unlock.html" title="svn unlock" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">svn switch</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="svn.ref.svn.c.status.html">Prev</a> </td><th width="60%" align="center"><span class="command"><strong>svn</strong></span> Subcommands</th><td width="20%" align="right"> <a accesskey="n" href="svn.ref.svn.c.unlock.html">Next</a></td></tr></table><hr /></div><div class="refentry" lang="en" xml:lang="en"><a id="svn.ref.svn.c.switch"></a><div class="titlepage"></div><a id="id421216" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn switch — Update working copy to a different URL.</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id421241"></a><h2>Synopsis</h2><pre class="programlisting">svn switch URL[@PEGREV] [PATH]</pre><pre class="programlisting">switch --relocate FROM TO [PATH...]</pre></div><div class="refsect1" lang="en" xml:lang="en"><a id="id421260"></a><h2>Description</h2><p>The first variant of this subcommand (without the <code class="option">--relocate</code> option) updates your working copy to point to a new URL—usually a URL which shares a common ancestor with your working copy, although not necessarily. This is the Subversion way to move a working copy to a new branch. If specified, <em class="replaceable"><code>PEGREV</code></em> determines in which revision the target is first looked up. See <a class="xref" href="svn.branchmerge.switchwc.html" title="Traversing Branches">the section called “Traversing Branches”</a> for an in-depth look at switching.</p><p> The <code class="option">--relocate</code> option causes <span class="command"><strong>svn switch</strong></span> to do something different: it updates your working copy to point to <span class="emphasis"><em>the same</em></span> repository directory, only at a different URL (typically because an administrator has moved the repository to another server, or to another URL on the same server).</p><p>If <code class="option">--force</code> 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.</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id421320"></a><h2>Alternate Names</h2><p>sw</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id421330"></a><h2>Changes</h2><p>Working copy</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id421340"></a><h2>Accesses Repository</h2><p>Yes</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id421350"></a><h2>Options</h2><pre class="screen"> --revision (-r) REV --depth ARG --ignore-externals --force --accept ARG --quiet (-q) --diff3-cmd CMD --relocate FROM TO --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR </pre></div><div class="refsect1" lang="en" xml:lang="en"><a id="id421364"></a><h2>Examples</h2><p>If you're currently inside the directory <code class="filename">vendors</code>, which was branched to <code class="filename">vendors-with-fix</code>, and you'd like to switch your working copy to that branch:</p><pre class="screen"> $ 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. </pre><p>And to switch back, just provide the URL to the location in the repository from which you originally checked out your working copy:</p><pre class="screen"> $ 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. </pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>You can just switch part of your working copy to a branch if you don't want to switch your entire working copy.</p></div><p>Sometimes an administrator might change the “<span class="quote">base location</span>” of your repository—in other words, the contents of the repository doesn't change, but the main URL used to reach the root of the repository does. For example, the hostname may change, the URL scheme may change, or any part of the URL which leads to the repository itself may change. Rather than check out a new working copy, you can have the <span class="command"><strong>svn switch</strong></span> command “<span class="quote">rewrite</span>” the beginnings of all the URLs in your working copy. Use the <code class="option">--relocate</code> option to do the substitution. No file contents are changed, nor is the repository contacted. It's similar to running a Perl script over your working copy <code class="filename">.svn/</code> directories which runs <span class="command"><strong>s/OldRoot/NewRoot/</strong></span>.</p><pre class="screen"> $ svn checkout file:///var/svn/repos test A test/a A test/b … $ mv repos newlocation $ cd test/ $ svn update svn: Unable to open an ra_local session to URL svn: Unable to open repository 'file:///var/svn/repos' $ svn switch --relocate file:///var/svn/repos file:///tmp/newlocation . $ svn update At revision 3. </pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Be careful when using the <code class="option">--relocate</code> option. If you mistype the argument, you might end up creating nonsensical URLs within your working copy that render the whole workspace unusable and tricky to fix. It's also important to understand exactly when one should or shouldn't use <code class="option">--relocate</code>. Here's the rule of thumb:</p><div class="itemizedlist"><ul type="disc"><li><p>If the working copy needs to reflect a new directory <span class="emphasis"><em>within</em></span> the repository, then use just <span class="command"><strong>svn switch</strong></span>.</p></li><li><p>If the working copy still reflects the same repository directory, but the location of the repository itself has changed, then use <span class="command"><strong>svn switch --relocate</strong></span>.</p></li></ul></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="svn.ref.svn.c.status.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="svn.ref.svn.html#svn.ref.svn.c">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="svn.ref.svn.c.unlock.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">svn status </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> svn unlock</td></tr></table></div></body></html>