Tag Archive for 'svn copy'

Subversion Tip of the Week

Using SVN Move

Apache Subversion’s ‘svn move’ command allows the user to move files and directories and can be applied to both the working copy and the repository. The key difference between this command and ‘svn copy,’ is that ‘svn move’ also deletes the original file. This makes running ‘svn move’ equivalent to performing an ‘svn copy’ followed by ‘svn delete.’

…in the Working Copy

Running this command at the working copy level requires you to specify the file you’re moving and the location you’re moving it to:

svn move (working-copy-path)/item-being-moved (working-copy-path)/new-location

In this example we’re moving the ‘Release2’ item to the ‘Releases’ directory.

svn move

Note, you’ll need to perform a commit to send this change to the repository and share it with the rest of your team.

…in the Repository

It’s also possible to move items inside the repository. As this creates a new revision, you’ll need to supply a log message alongside the command:

svn move (repository-URL)/item-being-moved -m “log message” (repository-URL)/new-location

In this example we’re moving the item ‘Release’ to the ‘Releases’ directory.

svn move 2

Looking for an easy-to-use cross platform Subversion client? Claim your free 30 day trial of SmartSVN Professional by visiting: www.smartsvn.com/download

All About SVN Copy

Apache Subversion’s commit command allows you to quickly create a copy of item(s) at both the working copy and the repository level. It’s most commonly used in creating branches.

In this tutorial, learn how to use the ‘svn copy’ command to copy file(s) in the working copy and the repository, alongside options such as copying items at specific revisions.

…in the Working Copy

The ‘svn copy’ command allows you to create a copy and place it in a new location within the working copy by running the command followed by the location of the item(s) you’re copying and the new location.

In this example, we’re creating a copy of the ‘Release3’ folder and placing it inside the ‘Releases’ directory.

svn copy (working-copy-path)/item-being-copied (working-copy-path)/item-being-created

svn copy

Check your working copy and you’ll see the file (‘Release4’) has successfully been created. Remember, this is a local change so you’ll need to perform an ‘svn commit’ to share it with the rest of your team.

svn copy 2

….in the Repository

Alternatively, you can create copies at the repository level. This change will automatically create a new revision so you’ll need to provide a log message alongside the ‘svn copy’ command.

svn copy (repository-URL)/item-being-copied -m “log message” (repository-URL)/item-being-created

svn copy 3

You can also copy item(s) as they existed in particular revisions, by specifying a revision number:

svn copy -r(revision-number) (repository-URL)/item-being-copied -m “log message” (repository-URL)/item-being-created

If no revision number is given, Subversion will default to HEAD.

 

svn copy 4

….Or Both 

Finally, you can copy item(s) between the working copy and the central repository. Note that when you’re copying to/from the repository, the usual rules apply: A log message is required, and the repo will copy the HEAD revision unless instructed otherwise.

In this example, we’re creating a copy of the “Release3” folder in the working copy and adding it to the repository as a folder called “Release5.”

svn copy 4

Want more advice on your Apache Subversion installation? We have a full series of SVN refcards for free download, covering hot topics such as branching and merging, and best practices. You can find out more at www.wandisco.com/svnref