All About SVN Copy
All About SVN Copy
Join the DZone community and get the full member experience.Join For Free
Do you need to strengthen the security of the mobile apps you build? Discover more than 50 secure mobile development coding practices to make your apps more secure.
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
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.
….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
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.
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 , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.