Name

svn copy — Copy a file or directory in a working copy or in the repository.

Synopsis

svn copy SRC[@REV]... DST

Description

Copy one or more files in a working copy or in the repository. When copying multiple sources, they will be added as children of DST, which must be a directory. SRC and DST can each be either a working copy (WC) path or URL:

WC -> WC

Copy and schedule an item for addition (with history).

WC -> URL

Immediately commit a copy of WC to URL.

URL -> WC

Check out URL into WC, and schedule it for addition.

URL -> URL

Complete server-side copy. This is usually used to branch and tag.

When copying multiple sources, they will be added as children of DST, which must be a directory.

If no peg revision (ie @REV) is supplied, by default the BASE revision will be used for files copied from the working copy, while the HEAD revision will be used for files copied from a URL.

Note

You can only copy files within a single repository. Subversion does not support cross-repository copying.

Alternate Names

cp

Changes

Repository if destination is a URL.

Working copy if destination is a WC path.

Accesses Repository

If source or destination is in the repository, or if needed to look up the source revision number.

Options

--message (-m) TEXT
--file (-F) FILE
--revision (-r) REV
--quiet (-q)
--parents
--with-revprop ARG
--username USER
--password PASS
--no-auth-cache
--non-interactive
--force-log
--editor-cmd EDITOR
--encoding ENC
--config-dir DIR

Examples

Copy an item within your working copy (just schedules the copy—nothing goes into the repository until you commit):

$ svn copy foo.txt bar.txt
A         bar.txt
$ svn status
A  +   bar.txt

Copy several files in a working copy into a subdirectory:

$ svn cp bat.c baz.c qux.c src
A         src/bat.c
A         src/baz.c
A         src/qux.c

Copy revision 8 of bat.c into your working copy under a different name:

$ svn cp bat.c ya-old-bat.c
A         ya-old-bat.c

Copy an item in your working copy to a URL in the repository (an immediate commit, so you must supply a commit message):

$ svn copy near.txt file:///var/svn/repos/test/far-away.txt -m "Remote copy."

Committed revision 8.

Copy an item from the repository to your working copy (just schedules the copy—nothing goes into the repository until you commit):

Tip

This is the recommended way to resurrect a dead file in your repository!

$ svn copy file:///var/svn/repos/test/far-away near-here
A         near-here

And finally, copying between two URLs:

$ svn copy file:///var/svn/repos/test/far-away file:///var/svn/repos/test/over-there -m "remote copy."

Committed revision 9.

Tip

This is the easiest way to “tag” a revision in your repository—just svn copy that revision (usually HEAD) into your tags directory.

$ svn copy file:///var/svn/repos/test/trunk file:///var/svn/repos/test/tags/0.6.32-prerelease -m "tag tree"

Committed revision 12.

And don't worry if you forgot to tag—you can always specify an older revision and tag anytime:

$ svn copy -r 11 file:///var/svn/repos/test/trunk file:///var/svn/repos/test/tags/0.6.32-prerelease -m "Forgot to tag at rev 11"

Committed revision 13.