如何从 svn 版本控制中删除文件而不从每个工作副本中删除它? [英] How do I remove a file from svn versioning without deleting it from every working copy?

查看:56
本文介绍了如何从 svn 版本控制中删除文件而不从每个工作副本中删除它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况是一堆文件被签入 svn,这些文件在源代码控制下非常烦人(特别是 log4j.properties 文件),我想将它们从版本控制中删除.我已经知道如何在我自己的本地工作副本中从 svn 版本控制中删除文件,如 这个问题这个,但这不是我要找的.

问题是,一旦我使用 svn rm --keep-local 删除文件,当其他每个用户都从存储库中提取他们的 log4j.properties 本地副本时会消失,他们的环境会崩溃.我想要做的是从存储库中的版本控制中删除该文件,但也要使其当其他人从存储库中提取时,就好像他们使用了 --keep-local他们自己的机器,这样他们的 log4j.properties 文件的现有副本就会保留下来,但没有版本化.

这甚至可以做到吗?我怀疑这是 svn 没有的功能.

解决方案

如果你真的有很多这样的文件,你可以使用 svndumpfilter 操作一石二鸟.这个想法是在服务器上转储存储库,过滤掉您不想保留的文件,并将结果加载到新的存储库中.然后你把新的而不是旧的.

当用户显然不访问存储库时,这必须小心完成.但它实际上会删除文件(当它们很大时很有趣)而不是将它们保留在历史记录中.作为副作用,下次用户进行更新时,这些文件将被忽略,就好像它们从未在存储库中一样.我们不得不这样做几次才能删除没有位置的二进制文件.

链接到相关文档.

简单示例(该命令当然提供了更大的灵活性):

svnadmin 创建 repos_newsvnadmin 转储仓库 |svndumpfilter 排除主干/log4j.properties |svnadmin 加载 repos_new

既然涉及到服务器上的仓库,我想再次强调,你应该采取预防措施(保留你的旧仓库).对于不那么烦人的文件,Don 不那么激烈,更可取.

为了避免这种情况,你可以在目录中设置相应的svn:ignore属性,你也可以鼓励人们使用全局忽略(不幸的是,它们必须在每个客户端上设置),甚至使用钩子脚本来预先拒绝文件类别.

My situation is that a bunch of files are checked into svn which are very annoying to have under source control (specifically a log4j.properties file), and I would like to remove them from version control. I already know how to remove a file from svn version control in my own local working copy, as in this question and this one, but that's not exactly what I'm looking for.

The problem is that once I remove the file with svn rm --keep-local, when every other user pulls from the repository their local copies of log4j.properties will disappear and their environments will crash. What I want to do is remove the file from version control in the repository, but also make it so that when everyone else pulls from the repository it will be as though they had used --keep-local on their own machines, so that the existing copy of their log4j.properties file sticks around but becomes unversioned.

Is this even possible to do? I suspect it's a feature that svn just doesn't have.

解决方案

If you really have a lot of such files, you can kill two birds with one stone by using a svndumpfilter operation. The idea is to make a dump of the repository on the server, filter out files you don't want to keep, and load the result in a new repository. Then you put the new one instead of the old one.

This has to be done with care, when users don't access the repository obviously. But it will actually remove the files (interesting when they are big) instead of keeping them in the history. As a side-effect, the next time a user does an update, these files will be ignored as if they were never in the repository. We had to do that a few times to remove binaries that didn't have their place there.

Link to the related documentation.

Simple example (the command offers more flexibility of course):

svnadmin create repos_new
svnadmin dump repos | svndumpfilter exclude trunk/log4j.properties | svnadmin load repos_new

Since it touches to the repository on the server, I want to emphasize again that you should take precautions (keep your old repository). For not-so-annoying files the method proposed by Don is less drastic and preferable.

To avoid this kind of situation, you can set the corresponding svn:ignore properties in the directories, you can also encourage people to use global ignores (they have to be set on each client unfortunately), or even use the hook-scripts to preemptively refuse categories of files.

这篇关于如何从 svn 版本控制中删除文件而不从每个工作副本中删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆