<?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>Creating a Working Copy</title> <link rel="stylesheet" type="text/css" href="styles.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.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.tour.html" title="Chapter 2. Basic Usage" /> <link rel="prev" href="svn.tour.importing.html" title="Getting Data into Your Repository" /> <link rel="next" href="svn.tour.cycle.html" title="Basic Work Cycle" /> </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">Creating a Working Copy</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="svn.tour.importing.html">Prev</a> </td> <th width="60%" align="center">Chapter 2. Basic Usage</th> <td width="20%" align="right"> <a accesskey="n" href="svn.tour.cycle.html">Next</a></td> </tr> </table> <hr /> </div> <div class="sect1" title="Creating a Working Copy"> <div class="titlepage"> <div> <div> <h2 class="title" style="clear: both"><a id="svn.tour.initial"></a>Creating a Working Copy</h2> </div> </div> </div> <p> <a id="idp7881264" class="indexterm"></a>Most of the time, you will start using a Subversion repository by performing a <em class="firstterm">checkout</em> of your project. Checking out a directory from a repository creates a working copy of that directory on your local machine. Unless otherwise specified, this copy contains the youngest (that is, most recently created or modified) versions of the directory and its children found in the Subversion repository:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout http://svn.example.com/svn/repo/trunk A trunk/README A trunk/INSTALL A trunk/src/main.c A trunk/src/header.h … Checked out revision 8810. $ </pre> </div> <p>Although the preceding example checks out the trunk directory, you can just as easily check out a deeper subdirectory of a repository by specifying that subdirectory's URL as the checkout URL:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout http://svn.example.com/svn/repo/trunk/src A src/main.c A src/header.h A src/lib/helpers.c … Checked out revision 8810. $ </pre> </div> <p>Since Subversion uses a copy-modify-merge model instead of lock-modify-unlock (see <a class="xref" href="svn.basic.version-control-basics.html#svn.basic.vsn-models" title="Versioning Models">the section called “Versioning Models”</a>), you can immediately make changes to the files and directories in your working copy. Your working copy is just like any other collection of files and directories on your system. You can edit the files inside it, rename it, even delete the entire working copy and forget about it.</p> <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Warning"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Warning]" src="images/warning.png" /> </td> <th align="left">Warning</th> </tr> <tr> <td align="left" valign="top"> <p>While your working copy is <span class="quote">“<span class="quote">just like any other collection of files and directories on your system,</span>”</span> you can edit files at will, but you must tell Subversion about <span class="emphasis"><em>everything else</em></span> that you do. For example, if you want to copy or move an item in a working copy, you should use <span class="command"><strong>svn copy</strong></span> or <span class="command"><strong>svn move</strong></span> instead of the copy and move commands provided by your operating system. We'll talk more about them later in this chapter.</p> </td> </tr> </table> </div> <p>Unless you're ready to commit the addition of a new file or directory or changes to existing ones, there's no need to further notify the Subversion server that you've done anything.</p> <div class="sidebar" title="What Is This .svn Directory?"> <div class="titlepage"> <div> <div> <p class="title"> <strong>What Is This .svn Directory?</strong> </p> </div> </div> </div> <p>The topmost directory of a working copy—and prior to version 1.7, every versioned subdirectory thereof—contains a special administrative subdirectory named <code class="filename">.svn</code>. Usually, your operating system's directory listing commands won't show this subdirectory, but it is nevertheless an important directory. Whatever you do, don't delete or change anything in the administrative area! Subversion uses that directory and its contents to manage your working copy.</p> </div> <p>Notice that in the previous pair of examples, Subversion chose to create a working copy in a directory named for the final component of the checkout URL. This occurs only as a convenience to the user when the checkout URL is the only bit of information provided to the <span class="command"><strong>svn checkout</strong></span> command. Subversion's command-line client gives you additional flexibility, though, allowing you to optionally specify the local directory name that Subversion should use for the working copy it creates. For example:</p> <div class="informalexample"> <pre class="screen"> $ svn checkout http://svn.example.com/svn/repo/trunk my-working-copy A my-working-copy/README A my-working-copy/INSTALL A my-working-copy/src/main.c A my-working-copy/src/header.h … Checked out revision 8810. $ </pre> </div> <p>If the local directory you specify doesn't yet exist, that's okay—<span class="command"><strong>svn checkout</strong></span> will create it for you.</p> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="svn.tour.importing.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="svn.tour.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="svn.tour.cycle.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">Getting Data into Your Repository </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> Basic Work Cycle</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>