SVN:递归忽略某些目录
我不希望任何名为 build
或 dist
的目录进入我的 SVN,无论它在树中有多深。
这可能吗?在 git 中,我只是将
build
dist
.gitignore
放在根目录中,它会递归地忽略。我如何使用 svn 来做到这一点?请不要告诉我在每个父目录上都做一个 propset...
I don't want any directory named build
or dist
to go into my SVN no matter how deep in the tree it is.
Is this possible? In git I just put
build
dist
in my .gitignore
at the root and it recursively ignores. How do I do this with svn? Please don't tell me to do a propset on every parent dir...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
从 subversion 1.8 开始,现在有
svn:global-ignores
属性,其工作方式类似于svn:ignore
但递归(因此将其设置在顶级目录中)As of subversion 1.8, there is now the
svn:global-ignores
property which works likesvn:ignore
but recursively (so set this on your top-level directory)svn propset
将--recursive
作为选项,因此您可以这样做,但有两个缺点:svn propset
takes--recursive
as an option, so you can do this, with two downsides:svn:ignore
property whenever you add a new directory这对我有用:
This works for me:
添加到您的 ~/.subversion/config 或 /etc/subversion/config 文件:
add to your ~/.subversion/config or /etc/subversion/config file:
通过从版本控制中删除目录,可以忽略构建和发行目录。诀窍是使用 --keep-local 选项将目录保留在工作副本中。例如:
该目录将不再被 subversion 跟踪,但它仍然存在于您的工作副本中以保存编译器输出等。
干杯,
乔
It is possible to ignore build and dist dirs by removing the directories from version control. The trick is to use the --keep-local option to leave the directory in the working copy. For example:
The directory will no longer be tracked by subversion but it will still be there in your working copy to hold compiler output, etc.
cheers,
joe
在 Subversion 1.8 以上,可以为当前存储库设置全局忽略。
您还可以创建一个名为 .svnignore 的文件夹,并写入条件。
记住每行一个条件,设置 build/* 或 dist/debug 是徒劳的。
然后执行命令:
In subversion 1.8 over, it is possible to set global-ignores for current repository.
Also you can create a folder named .svnignore, and write conditions.
remember one condition per line, setting build/* or dist/debug is in vain.
Then do the command:
例如文件夹结构:
最好在忽略命令之前对 dist 内容执行 svn delete,这样对于分支 dist 将为空。
为我工作,今天测试。
这是解释它的页面一点
For example the folder structure:
It's good to do a svn delete of dist content before the ignore command, so for branches dist will be empty.
Worked for me, tested today.
Here is the page explaining it a bit
为了忽略所有存储库中的所有此类文件,您可以将
global-ignores
添加到每个用户的配置文件中。请参阅配置选项
不幸的是,没有针对每个存储库的选项来执行此操作。它基本上是针对每个用户或每个目录的,因此多个
svn:ignores
可能是可行的方法,尽管它可能很烦人。In order to ignore all such files in all repositories, you could add a
global-ignores
to your per-user configuration file.See Configuration Options
Unfortunately, there's no per-repository option to do this. It's basically per-user, or per-directory, so the multiple
svn:ignores
is probably the way to go, as annoying as it can be.您首先必须移动到工作副本的顶部文件夹并在那里创建一个文件(例如 .svnignore),您应该在其中放置您想要忽略的所有模式,例如(对于 Android 项目):
然后运行以下命令(请记住,您必须位于工作副本的顶层文件夹):
这仅适用于尚未受版本控制的文件夹和文件。如果您希望正在版本控制的文件夹(或文件)也开始被忽略,请通过运行以下命令将其从版本控制中删除:
从这篇解释这一切的精彩文章中获取所有这些:http://superchlorine.com/2013/08/getting-svn-to-ignore-文件和目录/
You first have to move to the top folder of your working copy and create a file there (say .svnignore) where you should place all the patterns that you want to be ignored, for example (for an Android project):
Then you run the following command (remember that you must be at the top folder of your working copy):
This will only work for folders and files that are not yet under version control. If you want a folder (or file) that is being versioned to start being ignored as well, remove it from version control by running the command:
Got all this from this great article that explains it all: http://superchlorine.com/2013/08/getting-svn-to-ignore-files-and-directories/
创建一个文件并将您的忽略添加到其中
inore-list:
然后应用以下命令
目录是您的目录的名称,您也可以对目录/子目录进行子分类。或者使用 * 来记下您所在的当前目录。
这是假设您使用 bash 作为 shell
Create a file and add your ignores into it
ingore-list:
then apply the following command
directory is name of your directory, you can sub categorize as well directory/sub-directory. Or use * to note current directory you are under.
This is assuming you are using bash as your shell
其中 svn_ignore_rules 是一个包含忽略规则的文件 - 每行一个
当然,每次向存储库添加新目录时都必须重新运行它
svn_ignore_rules 也可以被视为签入存储库,以便可重复使用由对存储库具有写入权限的其他用户执行
where svn_ignore_rules is a file containing the ignore rules -- one per line
Of course you have to re-run it every time you add a new directory to your repo
svn_ignore_rules can also be considered to be checked into the repo, to be re-useable by other users having write access to the repo
一种方法是向提交前或提交后挂钩添加某种检查,但如果您不拥有存储库服务器,则需要直接注意。
One way would be to add some kind of check to either the pre- or post- commit hook but it's note straight forward if you don't own the repo server.
由于这个可能常见的问题似乎没有解决方案,我想分享我们的解决方案。正如其他人已经明确指出的那样,您可以使用
svn:ignore
属性,这适用于单个目录(因此不适用于新目录),或者使用global-ignores
code> 适用于单个用户(但不属于存储库)。为了让生活更轻松一些,我创建了一个名为
Settings.Svn.reg
的 reg 文件,并将其添加到存储库的根目录中。现在每个人都可以双击这个regfile一次,并完成设置。我真的很感激 SVN 存储库中的解决方案,所以如果有人知道,您愿意分享吗?
Since there seems to be no solution for this probably common problem, i would like to share our solution. As the others already made clear, you can either use the
svn:ignore
property, this applies to a single directory (and therefore not for new ones), or you useglobal-ignores
which applies to a single user (but doesn't belong to the repository).To make life a bit easier i created a reg file named
Settings.Svn.reg
and added it to the root of the repository. Now everybody can doublecklick this regfile once, and has the settings done.I would really appreciate a solution within the SVN repository, so if somebody knows, would you care to share it?