本手册旨在描述 Subversion 的 1.6.x 版本系列。如果您正在运行其他版本的 Subversion,强烈建议您访问 https://svnbook.subversion.org.cn/ 并查阅适合您 Subversion 版本的文档。
svn delete (del, remove, rm) — 从工作副本或存储库中删除项目。
由 PATH
指定的项目将在下次提交时被安排删除。文件(以及尚未提交的目录)将立即从工作副本中删除,除非指定了 --keep-local
选项。该命令不会删除任何未版本化的或修改过的项目;使用 --force
选项可覆盖此行为。
通过立即提交,从存储库中删除由 URL 指定的项目。多个 URL 将被原子地提交。
--editor-cmd CMD --encoding ENC --file (-F) FILENAME --force --force-log --keep-local --message (-m) MESSAGE --quiet (-q) --targets FILENAME --with-revprop ARG
使用 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: Attempting restricted operation for modified resource svn: Use --force to override this restriction svn: 'over-there' has local modifications $ 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 $