如何从版本控制中删除文件而不删除它?

发布于 2024-09-16 08:02:29 字数 176 浏览 1 评论 0原文

如果我运行 svn rm file ,该文件将从本地工作副本中删除。

我现在要做的是:

$ cp file file2
$ svn rm file
$ svn ci
$ mv file2 file

如何避免使用 svn rm 时 svn 也删除本地文件?

If I run svn rm file, the file is removed from the local working copy.

What I do now is:

$ cp file file2
$ svn rm file
$ svn ci
$ mv file2 file

How do I avoid svn also deleting the local file when using svn rm?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

天生の放荡 2024-09-23 08:02:29

您需要 --keep-local 命令行选项。这会将文件从版本控制中删除,而不将其从文件系统中删除。

$ svn rm --keep-local my_important_file

注意: --keep-local 仅影响副本的 svn rm。其他用户可能会删除自己的文件本地副本,除非他们的本地副本与存储库之间由于他们所做的更改而发生冲突。这可能不是期望的结果。请参阅下面的评论。

You want the --keep-local command-line option. This removes the file from version control without removing it from your filesystem.

$ svn rm --keep-local my_important_file

Note: The --keep-local only affects the svn rm of your copy. Other users may have their own local copy of the file deleted unless there is a conflict between their local copy and the repository due to changes they have made. This may not be the desired outcome. See comments below.

弥繁 2024-09-23 08:02:29

从 SVN 中删除文件而不在本地删除它是一个常见问题。一个突出的例子是 Eclipse 项目中的 .classpath 文件。只要项目中使用的所有机器都安装相同的 Eclipse 和 Java,将这个配置文件放在 SVN 下就很棒了。一旦违反此条件,提交就会开始破坏其他 Eclipse 项目。这就是必须从 SVN 中删除文件而不删除任何地方的要点。

svn rm --keep-local .classpath

在一台机器上并在那个时间点完美地完成这项工作。

问题是其他机器可能会丢失该文件(更新时)或复活它(提交时)。 SVN 的缺陷既不处理存储库中的 --keep-local 也不将其传播到其他工作副本。因此,在所有其他机器上,必须执行上述命令 - 最好在任何提交或更新之前执行。

当然,这充其量只能达到 90% 的效果。删除和重新版本控制会突然发生。我的解决方案是让我可以直接或间接访问的每台机器都执行此操作,

svn rm --keep-local .classpath
copy .classpath .classpath-nameOfTheMachine
svn add .classpath-nameOfTheMachine

这实在是太丑陋了,很难被称为“解决方案”。尽管如此,它总是允许对以后发生的任何事故进行快速修复。

Removing a file from SVN without deleting it locally nowhere is a common problem. One prominent example is the file .classpath in an Eclipse project. Putting this configuration file under SVN is marvellous as long as all machines used in the project have the same Eclipse and Java installation. Once this condition is violated commits start to break other Eclipse projects. This is the point one has to remove a file from SVN without deleting ist anywhere.

svn rm --keep-local .classpath

does the job perfectly on one machine and at that point in time.

Problem is other machines may lose that file (on update) or resurrect it (on commit). SVN's flaw is neither to handle --keep-local in the repository nor to propagate it to other working copies. Hence on all other machines above command has to be executed — best before any commit or update.

This, of course, will work 90%, at best. Deletes and re-versionings will happen out of a sudden. My solution is to have every machine, I have direct or indirect access to, do

svn rm --keep-local .classpath
copy .classpath .classpath-nameOfTheMachine
svn add .classpath-nameOfTheMachine

This is so outright ugly to be hardly called a "solution". Nevertheless it always allowed quick repairs of any later accidents.

傾旎 2024-09-23 08:02:29

对于那些在 svn 上使用 GUI 的人,请使用以下步骤从 svn 版本控制中删除文件,但将其保留在本地。
输入图片此处描述

for those who use GUI on svn, use below steps to remove a file from svn version control but retain it locally.
enter image description here

浮华 2024-09-23 08:02:29

我没有这个精确问题的答案,但我确实有一个相关问题的答案,即如何从版本控制中删除目录中的所有文件(即不是特定文件),而不在本地删除它们。该解决方案来自 Scientific Linux 实现。

ls -a .svn

应显示存储控制数据的 svn 目录。简单地说:

rm -r .svn

将删除这个目录。然后输入:

svn status

将产生“警告:此目录不是工作副本”错误,因为它不再受版本控制。

我希望这有帮助。

I do not have an answer to this precise question, but I do have an answer to a related question, which is how to remove all files (i.e. not a specific one) in a directory from version control without deleting them locally. This solution comes from a Scientific Linux implementation.

ls -a .svn

should show the svn directory that stores control data. Simply:

rm -r .svn

will get rid of this directory. Then typing:

svn status

will produce a 'warning: this directory is not a working copy' error, because it is no longer under version control.

I hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文