使用 svn:ignore 忽略除某些文件之外的所有内容
使用 svn:ignore 属性,有没有一种方法可以根据我不想忽略的模式指定我想要忽略的内容? 换句话说,我想忽略除以 .xyz 结尾的文件之外的所有内容。 我将如何去做(如果可能的话)?
我探索过的一种选择是提交我想要进行版本控制的所有内容,然后将目录上的 svn:ignore 属性设置为“*”,这意味着除了我已经提交的文件之外,不会有其他文件进行版本控制。 这是我能想到的最好的办法,但感觉很脏,因为如果我确实需要添加另一个文件作为版本,我必须进行多次提交......一个删除 svn:ignore 属性,另一个添加/提交新文件,然后第三个将 svn:ignore 更改回“*”。
你的想法?
With the svn:ignore property, is there a way I can specify what I want to ignore based on patterns which I don't want to ignore? In other words, I want to ignore everything but files ending in .xyz. How would I go about doing that (if it's even possible)?
One option I've explored is committing everything I want to be versioned, then setting the svn:ignore property on the directory to be '*', thus meaning no other files but what I've already committed will be versioned. This is the best I can come up with, but it feels dirty in that if I ever did need to add another file to be version, I'd have to make multiple commits... one to remove the svn:ignore property, another to add/commit the new file(s), and then a third to change svn:ignore back to '*'.
Your thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
看看 对 Subversion 的 svn 使用否定模式:忽略属性。 显然你可以使用“!” 在字符组中否定其含义。 因此,如果您想忽略除以 .java 结尾的文件之外的所有内容,请将以下模式设置为 svn:ignore:
Have a look at Using negative patterns for Subversion's svn:ignore property. Obviously you can use "!" in character groups to negate its meaning. So if you want to ignore everything except files ending with .java, set the following pattern to svn:ignore:
不,不存在您所描述的独家匹配。 本文列出了模式匹配。 它仅限于:
?
- 匹配任何单个字符*
- 匹配任何字符串,包括空字符串[
- 开始字符类定义由]
终止,用于匹配字符子集类似的问题已经被问过
No, there is no exclusive matching like you described. This article lists the possibilities for pattern matching. It's limited to:
?
- Matches any single character*
- Matches any string of characters, including the empty string[
- Begins a character class definition terminated by]
, used for matching a subset of charactersA similar question was asked already here.
这是我所知道的唯一解决方案。 即使文件被忽略,您也可以显式添加它们。
不过,您需要在所有子目录中添加该设置。
That's the only solution I know of. You can explicitly add files even if they are ignored though.
You would need to add that setting on all subdirectories though.
这是我在
bin
文件夹中为svn:ignore
属性设置的内容,以匹配除 apk 文件之外的所有内容:如果有完整的 RegExp 支持,您可以使用负向后查找,但那就是无论如何很少实现(例如不在 JavaScript 中)并且效率低下。
This is what I have set on
bin
folder forsvn:ignore
property to match everything except apk files:If there would be full RegExp support you could use negative lookbehind, but that's rarely implemented anyway (e.g not in JavaScript) and is inefficient.
以下内容对我有用,并消除了其他建议的一些怪癖。
逐行解释如下:
内容限制:
The following works for me and gets rid of a few quirks of the other suggestions.
A line by line explanation follows:
Limitations:
好吧,我不知道我是否错过了一些东西,但是您可以使用您想要的任何模式:
您可以检查:
另一种方法是使用可以在提交时进行复杂解析的别名/脚本。
我发现自己使用的最佳解决方案是将源文件的版本树与构建树完全分离。 这样,您就不会在目录的版本树中生成内容。 那么你只能使用 svn:ignore 来忽略由文本编辑器生成的简单人工制品。
编辑:
抱歉我对第一个解决方案的错误,我误读了你的帖子。 即使不完全是您想要的,其他两种方式似乎也相关......
Well, I don't know if I miss something, but you can use any pattern you want:
You can check with:
Another way is to use an alias / script that can do complex parsing when committing.
The best solution I find to use myself is to completely separate the versioned tree of source files from the build tree. This way you do not generate things in your versioned tree of a directory. Then you can only use
svn:ignore
to ignore simple artefacts generated by text editors for example.EDIT:
Sorry my mistake for the first solution, I have misread your post. The two other ways seems relevant even if not exactly what you want...