名称

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

概要

svn copy SRC[@REV]... DST

描述

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

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

WC → URL

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

URL → WC

Check out URL into WC and schedule it for addition.

URL → URL

完全的服务器端拷贝,通常用在分支和标签。

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

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.

注意

你只可以在单个版本库中拷贝文件,Subversion还不支持跨版本库的拷贝。

Alternate Name

cp

改变

如果目标是URL则包括版本库。

如果目标是WC路径,则是工作拷贝。

是否访问版本库

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

选项

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

例子

拷贝工作拷贝的一个项目(只是预定要拷贝—在提交之前不会影响版本库):

$ 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

拷贝你的工作拷贝的一个项目到版本库的URL(直接的提交,所以需要提供一个提交信息):

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

Committed revision 8.

拷贝版本库的一个项目到你的工作拷贝(只是预定要拷贝—在提交之前不会影响版本库):

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

提示

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

And finally, copy 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.
$ svn copy file:///var/svn/repos/test/trunk \
    file:///var/svn/repos/test/tags/0.6.32-prerelease -m "tag tree"

Committed revision 12.

提示

这是在版本库里作“标签”最简单的方法—svn copy那个修订版本(通常是HEAD)到你的tags目录。

不要担心忘记作标签—你可以在以后任何时候给一个旧版本作标签:

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