<?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 copy (cp)</title> <link rel="stylesheet" type="text/css" href="styles.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /> <style type="text/css"> body { background-image: url('images/draft.png'); background-repeat: no-repeat; background-position: top left; /* The following properties make the watermark "fixed" on the page. */ /* I think that's just a bit too distracting for the reader... */ /* background-attachment: fixed; */ /* background-position: center center; */ }</style> <link rel="home" href="index.html" title="Version Control with Subversion [DRAFT]" /> <link rel="up" href="svn.ref.svn.html" title="svn Reference—Subversion Command-Line Client" /> <link rel="prev" href="svn.ref.svn.c.commit.html" title="svn commit (ci)" /> <link rel="next" href="svn.ref.svn.c.delete.html" title="svn delete (del, remove, rm)" /> </head> <body> <div xmlns="" id="vcws-version-notice"> <p>This text is a work in progress—highly subject to change—and may not accurately describe any released version of the Apache™ Subversion® software. Bookmarking or otherwise referring others to this page is probably not such a smart idea. Please visit <a href="http://www.svnbook.com/">http://www.svnbook.com/</a> for stable versions of this book.</p> </div> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">svn copy (cp)</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="svn.ref.svn.c.commit.html">Prev</a> </td> <th width="60%" align="center">svn Reference—Subversion Command-Line Client</th> <td width="20%" align="right"> <a accesskey="n" href="svn.ref.svn.c.delete.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="svn.ref.svn.c.copy"></a> <div class="titlepage"></div> <a id="idm11297" class="indexterm"></a> <div class="refnamediv"> <h2>Name</h2> <p>svn copy (cp) — Copy a file or directory in a working copy or in the repository.</p> </div> <div class="refsynopsisdiv"> <h2>Synopsis</h2> <p> <code class="literal">svn copy SRC[@REV]... DST</code> </p> </div> <div class="refsect1"> <a id="idm11307"></a> <h2>Description</h2> <p>Copy one or more files in a working copy or in the repository. <em class="replaceable"><code>SRC</code></em> and <em class="replaceable"><code>DST</code></em> can each be either a working copy (WC) path or URL. When copying multiple sources, add the copies as immediate children of <em class="replaceable"><code>DST</code></em> (which, of course, must be an existing directory).</p> <div class="variablelist"> <dl class="variablelist"> <dt> <span class="term">WC → WC</span> </dt> <dd> <p>Copy and schedule an item for addition (with history).</p> </dd> <dt> <span class="term">WC → URL</span> </dt> <dd> <p>Immediately commit a copy of WC to URL.</p> </dd> <dt> <span class="term">URL → WC</span> </dt> <dd> <p>Check out URL into WC and schedule it for addition.</p> </dd> <dt> <span class="term">URL → URL</span> </dt> <dd> <p>Complete server-side copy. This is usually used to branch and tag.</p> </dd> </dl> </div> <p>If no peg revision (i.e., <em class="replaceable"><code>@REV</code></em>) is supplied, by default the <code class="literal">BASE</code> revision will be used for files copied from the working copy, while the <code class="literal">HEAD</code> revision will be used for files copied from a URL.</p> <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>You can only copy files within a single repository. Subversion does not support cross-repository copying.</p> </td> </tr> </table> </div> </div> <div class="refsect1"> <a id="idm11336"></a> <h2>Options</h2> <div class="informalexample"> <pre class="screen"> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.parents"><code class="option">--parents</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre> </div> </div> <div class="refsect1"> <a id="idm11350"></a> <h2>Examples</h2> <p>Copy an item within your working copy (this schedules the copy—nothing goes into the repository until you commit):</p> <div class="informalexample"> <pre class="screen"> $ svn copy foo.txt bar.txt A bar.txt $ svn status A + bar.txt </pre> </div> <p>Copy several files in a working copy into a subdirectory:</p> <div class="informalexample"> <pre class="screen"> $ svn copy bat.c baz.c qux.c src A src/bat.c A src/baz.c A src/qux.c </pre> </div> <p>Copy revision 8 of <code class="filename">bat.c</code> into your working copy under a different name:</p> <div class="informalexample"> <pre class="screen"> $ svn copy -r 8 bat.c ya-old-bat.c A ya-old-bat.c </pre> </div> <p>Copy an item in your working copy to a URL in the repository (this is an immediate commit, so you must supply a commit message):</p> <div class="informalexample"> <pre class="screen"> $ svn copy near.txt file:///var/svn/repos/test/far-away.txt -m "Remote copy." Committed revision 8. </pre> </div> <p>Copy an item from the repository to your working copy (this just schedules the copy—nothing goes into the repository until you commit):</p> <div class="informalexample"> <pre class="screen"> $ svn copy file:///var/svn/repos/test/far-away -r 6 near-here A near-here </pre> </div> <div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Tip"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Tip]" src="images/tip.png" /> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>This is the recommended way to resurrect a dead file in your repository!</p> </td> </tr> </table> </div> <p>And finally, copy between two URLs:</p> <div class="informalexample"> <pre class="screen"> $ svn copy file:///var/svn/repos/test/far-away \ file:///var/svn/repos/test/over-there -m "remote copy." Committed revision 9. </pre> </div> <div class="informalexample"> <pre class="screen"> $ svn copy file:///var/svn/repos/test/trunk \ file:///var/svn/repos/test/tags/0.6.32-prerelease -m "tag tree" Committed revision 12. </pre> </div> <div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Tip"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Tip]" src="images/tip.png" /> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>This is the easiest way to <span class="quote">“<span class="quote">tag</span>”</span> a revision in your repository—just <span class="command"><strong>svn copy</strong></span> that revision (usually <code class="literal">HEAD</code>) into your <code class="filename">tags</code> directory.</p> </td> </tr> </table> </div> <p>And don't worry if you forgot to tag—you can always specify an older revision and tag anytime:</p> <div class="informalexample"> <pre class="screen"> $ svn copy -r 11 file:///var/svn/repos/test/trunk \ file:///var/svn/repos/test/tags/0.6.32-prerelease \ -m "Forgot to tag at rev 11" Committed revision 13. </pre> </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.commit.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="svn.ref.svn.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="svn.ref.svn.c.delete.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">svn commit (ci) </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> svn delete (del, remove, rm)</td> </tr> </table> </div> <div xmlns="" id="vcws-footer"> <hr /> <img src="images/cc-by.png" style="float: right;" /> <p>You are reading <em>Version Control with Subversion</em> (for Subversion 1.8), by Ben Collins-Sussman, Brian W. Fitzpatrick, and C. Michael Pilato.</p> <p>This work is licensed under the <a href="http://creativecommons.org/licenses/by/2.0/">Creative Commons Attribution License v2.0</a>.</p> <p>To submit comments, corrections, or other contributions to the text, please visit <a href="http://www.svnbook.com/">http://www.svnbook.com/</a>.</p> </div> </body> </html>