本手册旨在描述 Apache™ Subversion® 的 1.7.x 系列。如果您运行的是其他版本的 Subversion,强烈建议您访问 https://svnbook.subversion.org.cn/,并查阅适合您 Subversion 版本的手册。

名称

svn delete (del, remove, rm) — 从工作副本或仓库中删除项目。

概要

svn delete PATH...

svn delete URL...

描述

PATH 指定的项目将在下次提交时被安排删除。文件(以及未提交的目录)将立即从工作副本中删除,除非指定了 --keep-local 选项。该命令不会删除任何未版本化或已修改的项目;使用 --force 选项来覆盖此行为。

通过 URL 指定的项目将通过立即提交从仓库中删除。多个 URL 将原子地提交。

选项

示例

使用 svn 从工作副本中删除文件会删除您对该文件的本地副本,但它只是将该文件安排从仓库中删除。当您提交时,该文件将在仓库中被删除。

$ svn delete myfile
D         myfile

$ svn commit -m "Deleted file 'myfile'."
Deleting       myfile
Transmitting file data .
Committed revision 14.

但是,删除 URL 是立即进行的,因此您必须提供日志消息

$ svn delete -m "Deleting file 'yourfile'" \
             file:///var/svn/repos/test/yourfile

Committed revision 15.

以下是如何强制删除具有本地修改的文件的示例

$ svn delete over-there 
svn: E195006: Use --force to override this restriction (local modifications m\
ay be lost)
svn: E195006: '/home/sally/project/over-there' has local modifications -- com\
mit or revert them first
$ svn delete --force over-there 
D         over-there
$

使用 --keep-local 选项来覆盖默认的 svn delete 行为,即也删除已安排版本化删除的目标文件。当您意识到您不小心提交了需要保留在工作副本中的文件的添加,但该文件不应该添加到版本控制中时,这很有用。

$ svn delete --keep-local conf/program.conf
D         conf/program.conf

$ svn commit -m "Remove accidentally-added configuration file."
Deleting       conf/program.conf
Transmitting file data .
Committed revision 21.
$ svn status
?       conf/program.conf
$