Section 5.5. Changing the Working Copy Target


5.5. Changing the Working Copy Target

Inside a working copy, Subversion makes it fairly simple to move files and directories between different revisions, and even different repositories. For the most part, movement between revisions is done using the svn update command. Running svn update, by default, updates a file or directory in a working copy to the latest revision in the repository. However, if you supply a --revision (-r) option when the command is run, Subversion instead updates the file in the working copy to that revision, even if it is prior to the current revision in the repository.

 $ svn update --revision 1773 foo.c U foo.c 

In addition to moving between revisions with svn update, you can also use the svn switch command to change a working copy's URL. This allows you, for instance, to switch a directory to a branch. As an example, the following svn switch command switches the trunk directory in the working copy to instead represent the mybranch branch in the branches directory.

 $ svn switch http://svn.example.com/repos/branches/mybranch trunk/ U foo.c A foo.h U bar.c U Makefile D README.txt 

The preceding use of svn switch requires that the given URL be in the same repository as the working copy. You can, however, also use svn switch to completely change the repository that a working copy looks to. This is done by running the command with the --relocate option, which goes through a working copy and changes the base URL of every file or directory that matches the given original base (think find and replace). For example, the following example shows a URL relocation of the working copy trunk directory (and its contents) from example.com to example.net.

$ svn switch --relocate http://svn.example.com/repos http://svn.example.net/repos trunk/ 



    Subversion Version Control. Using The Subversion Version Control System in Development Projects
    Subversion Version Control. Using The Subversion Version Control System in Development Projects
    ISBN: 131855182
    EAN: N/A
    Year: 2005
    Pages: 132

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net