<?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 checkout (co)</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.changelist.html" title="svn changelist (cl)" /> <link rel="next" href="svn.ref.svn.c.cleanup.html" title="svn cleanup" /> </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 checkout (co)</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="svn.ref.svn.c.changelist.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.cleanup.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="svn.ref.svn.c.checkout"></a> <div class="titlepage"></div> <a id="idm11142" class="indexterm"></a> <div class="refnamediv"> <h2>Name</h2> <p>svn checkout (co) — Check out a working copy from a repository.</p> </div> <div class="refsynopsisdiv"> <h2>Synopsis</h2> <p> <code class="literal">svn checkout URL[@REV]... [PATH]</code> </p> </div> <div class="refsect1"> <a id="idm11152"></a> <h2>Description</h2> <p>Check out a working copy from a repository. If <em class="replaceable"><code>PATH</code></em> is omitted, the basename of the URL will be used as the destination. If multiple URLs are given, each will be checked out into a subdirectory of <em class="replaceable"><code>PATH</code></em>, with the name of the subdirectory being the basename of the URL.</p> </div> <div class="refsect1"> <a id="idm11157"></a> <h2>Options</h2> <div class="informalexample"> <pre class="screen"> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.force"><code class="option">--force</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.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> </pre> </div> </div> <div class="refsect1"> <a id="idm11166"></a> <h2>Examples</h2> <p>Check out a working copy into a directory called <code class="filename">mine</code>:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout file:///var/svn/repos/test mine A mine/a A mine/b A mine/c A mine/d Checked out revision 20. $ ls mine $ </pre> </div> <p>Check out two different directories into two separate working copies:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout file:///var/svn/repos/test \ file:///var/svn/repos/quiz A test/a A test/b A test/c A test/d Checked out revision 20. A quiz/l A quiz/m Checked out revision 13. $ ls quiz test $ </pre> </div> <p>Check out two different directories into two separate working copies, but place both into a directory called <code class="filename">working-copies</code>:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout file:///var/svn/repos/test \ file:///var/svn/repos/quiz \ working-copies A working-copies/test/a A working-copies/test/b A working-copies/test/c A working-copies/test/d Checked out revision 20. A working-copies/quiz/l A working-copies/quiz/m Checked out revision 13. $ ls working-copies </pre> </div> <p>If you interrupt a checkout (or something else interrupts your checkout, such as loss of connectivity, etc.), you can restart it either by issuing the identical checkout command again or by updating the incomplete working copy:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout file:///var/svn/repos/test mine A mine/a A mine/b ^C svn: E200015: Caught signal $ svn checkout file:///var/svn/repos/test mine A mine/c ^C svn: E200015: Caught signal $ svn update mine Updating 'mine': A mine/d Updated to revision 20. $ </pre> </div> <p>If you wish to check out some revision other than the most recent one, you can do so by providing the <code class="option">--revision</code> (<code class="option">-r</code>) option to the <span class="command"><strong>svn checkout</strong></span> command:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout -r 2 file:///var/svn/repos/test mine A mine/a Checked out revision 2. $ </pre> </div> <p>Prior to version 1.7, Subversion would complain by default if you try to check out a directory atop an existing directory which contains files or subdirectories that the checkout itself would have created. Subversion 1.7 handles this situation differently, allowing the checkout to proceed but marking any obstructing objects as tree conflicts. Use the <code class="option">--force</code> option to override this safeguard. When you check out with the <code class="option">--force</code> option, any unversioned file in the checkout target tree which ordinarily would obstruct the checkout will still become versioned, but Subversion will preserve its contents as-is. If those contents differ from the repository file at that path (which was downloaded as part of the checkout), the file will appear to have local modifications—the changes required to transform the versioned file you checked out into the unversioned file you had before checking out—when the checkout completes.</p> <div class="informalexample"> <pre class="screen"> $ mkdir project $ mkdir project/lib $ touch project/lib/file.c $ svn checkout file:///var/svn/repos/project/trunk project --force E project/lib A project/lib/subdir E project/lib/file.c A project/lib/anotherfile.c A project/include/header.h Checked out revision 21. $ svn status wc M project/lib/file.c $ svn diff wc Index: project/lib/file.c =================================================================== --- project/lib/file.c (revision 1) +++ project/lib/file.c (working copy) @@ -3 +0,0 @@ -/* file.c: Code for acting file-ishly. */ -#include <stdio.h> -/* Not feeling particularly creative today. */ $ </pre> </div> <p>As in another other working copy, you have the choices typically available: reverting some or all of those local <span class="quote">“<span class="quote">modifications</span>”</span>, committing them, or continuing to modify your working copy.</p> <p>This feature is especially useful for performing in-place imports of unversioned directory trees. By first importing the tree into the repository, and then checking out new repository location atop the unversioned tree with the <code class="option">--force</code> option, you effectively transform the unversioned tree into a working copy.</p> <div class="informalexample"> <pre class="screen"> $ svn mkdir -m "Create newproject project root." \ file://var/svn/repos/newproject $ svn import -m "Import initial newproject codebase." newproject \ file://var/svn/repos/newproject/trunk Adding newproject/include Adding newproject/include/newproject.h Adding newproject/lib Adding newproject/lib/helpers.c Adding newproject/lib/base.c Adding newproject/notes Adding newproject/notes/README Committed revision 22. $ svn checkout file://`pwd`/repos-1.6/newproject/trunk newproject --force E newproject/include E newproject/include/newproject.h E newproject/lib E newproject/lib/helpers.c E newproject/lib/base.c E newproject/notes E newproject/notes/README Checked out revision 2. $ svn status newproject $ </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.changelist.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.cleanup.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">svn changelist (cl) </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> svn cleanup</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>