• Initial Checkout

    Most of the time, you will start using a Subversion repository by doing a checkout of your project. Checking out a repository creates a “working copy” of it on your local machine. This copy contains the HEAD (latest revision) of the Subversion repository that you specify on the command line:

    $ svn checkout http://svn.collab.net/repos/svn/trunk
    A    trunk/Makefile.in
    A    trunk/ac-helpers
    A    trunk/ac-helpers/install.sh
    A    trunk/ac-helpers/install-sh
    A    trunk/build.conf
    …
    Checked out revision 8810.
    

    Although the above example checks out the trunk directory, you can just as easily check out any deep subdirectory of a repository by specifying the subdirectory in the checkout URL:

    $ svn checkout \
          http://svn.collab.net/repos/svn/trunk/subversion/tests/cmdline/
    A    cmdline/revert_tests.py
    A    cmdline/diff_tests.py
    A    cmdline/autoprop_tests.py
    A    cmdline/xmltests
    A    cmdline/xmltests/svn-test.sh
    …
    Checked out revision 8810.
    

    Since Subversion uses a “copy-modify-merge” model instead of “lock-modify-unlock” (see the section called “Versioning Models”), you can start right in making 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 and change them, move them around, you can even delete the entire working copy and forget about it.

    Warning

    While your working copy is “just like any other collection of files and directories on your system”, you can edit files at will, but you must tell Subversion about everything else that you do. For example, if you want to copy or move an item in a working copy, you should use svn copy or svn move instead of the copy and move commands provided by your operating system. We'll talk more about them later in this chapter.

    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.

    While you can certainly check out a working copy with the URL of the repository as the only argument, you can also specify a directory after your repository URL. This places your working copy in the new directory that you name. For example:

    $  svn checkout http://svn.collab.net/repos/svn/trunk subv
    A    subv/Makefile.in
    A    subv/ac-helpers
    A    subv/ac-helpers/install.sh
    A    subv/ac-helpers/install-sh
    A    subv/build.conf
    …
    Checked out revision 8810.
    

    That will place your working copy in a directory named subv instead of a directory named trunk as we did previously. The directory subv will be created if it doesn't already exist.

    Disabling Password Caching

    When you perform a Subversion operation that requires you to authenticate, by default Subversion caches your authentication credentials on disk. This is done for convenience, so that you don't have to continually re-enter your password for future operations. If you're concerned about caching your Subversion passwords,[3] you can disable caching either permanently or on a case-by-case basis.

    To disable password caching for a particular one-time command, pass the --no-auth-cache option on the commandline. To permanently disable caching, you can add the line store-passwords = no to your local machine's Subversion configuration file. See the section called “Client Credentials Caching” for details.

    Authenticating as a Different User

    Since Subversion caches auth credentials by default (both username and password), it conveniently remembers who you were acting as the last time you modified you working copy. But sometimes that's not helpful–particularly if you're working in a shared working copy, like a system configuration directory or a webserver document root. In this case, just pass the --username option on the commandline and Subversion will attempt to authenticate as that user, prompting you for a password if necessary.



    [3] Of course, you're not terribly worried–first because you know that you can't really delete anything from Subversion and, secondly, because your Subversion password isn't the same as any of the other three million passwords you have, right? Right?


    The Version Control with Subversion book is licensed under the Creative Commons Attribution License v2.0.
    To submit comments, corrections, or other contributions to the text, please visit http://www.svnbook.com.