在 subversion 中递归忽略整个源代码树中的文件 [英] Recursively ignoring files in the entire source tree in subversion
问题描述
我对 Subversion 并不陌生,但到目前为止我一直使用 Tortoise 而从来没有使用过命令行.我的问题是,如何忽略整个源中的 *.o 之类的所有文件,而不仅仅是根目录.
例如,如果我有以下文件:/myfile.o/folder1/myfile2.o/folder1/folder1.1/myfile3.o/folder2/myfile4.o
如果 svn propedit svn:ignore "."在根目录下添加*.o,会忽略myfile.o,但不会忽略/folder1/myfile2.o、/folder1/folder1.1/myfile3.o、/folder2/myfile4.o.有没有办法为整个项目添加 *.o(我不能为整个存储库添加,我知道可以这样做,因为该项目与许多其他项目位于一个存储库中)?
如果我需要澄清,请告诉我.谢谢!
编辑
下面提供的原始答案是在 Subversion v1.8 之前给出的,它引入了一种设置默认存储库级别忽略的方法(称为 svn:global-ignores
),而无需覆盖/替换 svn:ignore
根目录和每个子目录上的属性.从 1.8 开始,实现您想要的最佳方式是调用以下命令(归功于 TManhente):
svn propset svn:global-ignores '*.o' .
在早期版本(和更高版本)上,您仍然可以使用下面原始答案中指示的方法;但是,请注意,这假设您可以替换/覆盖每个子目录上的 svn:ignore
属性......这对于小型/新存储库可能没问题,但可能不是什么如果您有一个大型/旧存储库,其中某些子目录可能具有您不想覆盖的独立 svn:ignore
属性,则您需要.
原答案
您可以将-R"或--recursive"选项与svn propset"一起使用,如下面的命令:
<前>svn propset svn:ignore '*.o' .--递归更多信息
对于这两种情况,您都可以使用以下命令获取有关 svn propset 的更多信息:
<前>svn 帮助属性集I am not new to Subversion, but I have up till now used Tortoise and never the commadn line. My question is, how do I ignore all files like *.o from the ENTIRE source not just the root.
For example, if I have the following files: /myfile.o /folder1/myfile2.o /folder1/folder1.1/myfile3.o /folder2/myfile4.o
If svn propedit svn:ignore "." in the root directory, and add *.o, it will ignore the myfile.o, but does not ignore /folder1/myfile2.o, /folder1/folder1.1/myfile3.o, /folder2/myfile4.o. Is there a way to add *.o in for an entire project (I cannot do it for the entire repository, which I know can be done, because this project is in a repository with many other projects)?
Please let me know if I need to clarify. Thanks!
Edit
The original answer provided below was given prior to Subversion v1.8 which introduced a way to set the default repository level ignore (called svn:global-ignores
) without overriding/replacing the svn:ignore
property on the root directory and every single subdirectory. Since 1.8, the best way to achieve what you would like is to invoke the following command (credit goes to TManhente):
svn propset svn:global-ignores '*.o' .
On earlier versions (and on later versions), you can still use the approach indicated in the original answer below; however, be aware that this assumes that you are okay with replacing/overwriting the svn:ignore
property on each and every subdirectory... this may be fine for a smallish/newish repository but is probably not what you want if you have a large/old repository in which some subdirectories may have independent svn:ignore
properties that you do not wish to overwrite.
Original answer
You can use the "-R" or "--recursive" option with "svn propset" as in the following command:
svn propset svn:ignore '*.o' . --recursive
More info
For both cases, you can use the following command for more info about svn propset:
svn help propset
这篇关于在 subversion 中递归忽略整个源代码树中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!