DevOps Zone is brought to you in partnership with:

Jessica Thornsby is the Technical and Creative Copywriter at WANdisco, where she writers regular tutorials on Apache Subversion, TortoiseSVN, uberSVN, and all things version control. She spends her spare time editing the CD reviews section at www.leedsmusicscene.net, contributing to A Short Fanzine About Rocking, and researching her family tree. You can find her on Twitter @jthornsby Jessica is a DZone MVB and is not an employee of DZone and has posted 29 posts at DZone. You can read more from them at their website. View Full User Profile

All About SVN Copy

03.08.2013
| 2721 views |
  • submit to reddit

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.”

Published at DZone with permission of Jessica Thornsby, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)