名称

svn copy (cp) — 拷贝工作副本的一个文件或目录到版本库。

概要

svn copy SRC[@REV]... DST

描述

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

WC → WC

拷贝并且预定一个添加的项目(包含历史)。

WC → URL

将WC或URL的拷贝立即提交。

URL → WC

检出URL到WC,并且加入到添加计划。

URL → URL

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

If no peg revision (i.e., @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.

[注意] 注意

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

选项

--editor-cmd CMD
--encoding ENC
--file (-F) FILENAME
--force-log
--ignore-externals
--message (-m) MESSAGE
--parents
--quiet (-q)
--revision (-r) REV
--with-revprop ARG

例子

Copy an item within your working copy (this 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

拷贝工作副本的一个文件或目录到版本库:

$ svn copy 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 copy -r 8 bat.c ya-old-bat.c
A         ya-old-bat.c

Copy an item in your working copy to a URL in the repository (this is 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 (this just schedules the copy—nothing goes into the repository until you commit):

$ svn copy file:///var/svn/repos/test/far-away -r 6 near-here
A         near-here
[提示] 提示

这是恢复死掉文件的推荐方式!

最后,是在URL之间拷贝:

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

Committed revision 9.
$ svn copy file:///var/svn/repos/test/trunk \
           file:///var/svn/repos/test/tags/0.6.32-prerelease -m "tag tree"

Committed revision 12.
[提示] 提示

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

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.