简体   繁体   English

SVN:递归地忽略一些目录

[英]SVN: Ignore some directories recursively

I don't want any directory named build or dist to go into my SVN no matter how deep in the tree it is. 我不希望任何名为builddist目录进入我的SVN,无论它在树中有多深。

Is this possible? 这可能吗? In git I just put 在git我刚刚放

build
dist

in my .gitignore at the root and it recursively ignores. 在我的.gitignore根目录,它递归忽略。 How do I do this with svn? 我怎么用svn做这个? Please don't tell me to do a propset on every parent dir... 请不要告诉我在每个父母的目录上做一个propset ...

从subversion 1.8开始,现在有svn:global-ignores属性,它的作用类似于svn:ignore但是递归(所以在你的顶级目录中设置它)

svn propset takes --recursive as an option, so you can do this, with two downsides: svn propset--recursive作为一个选项,所以你可以做到这一点,有两个缺点:

  1. you have to check out the entire repository (or at least all directories therein), and 你必须检查整个存储库(或至少其中的所有目录),和
  2. you have to remember to set the svn:ignore property whenever you add a new directory 你必须记住在添加新目录时设置svn:ignore属性

It is not possible to do this. 这是不可能的。 There are only two ignore mechanisms in Subversion, svn:ignore (which is nonrecursive) and global-ignores (which is not specific to a repository). Subversion中只有两种忽略机制, svn:ignore (非递归)和global-ignores (不特定于存储库)。

这对我有用:

 svn propset --recursive svn:ignore *.zip <dir_tree_with_no_zips>

add to your ~/.subversion/config or /etc/subversion/config file: 添加到〜/ .subversion / config或/ etc / subversion / config文件:

[miscellany]
global-ignores = build dist

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. 诀窍是使用--keep-local选项将目录保留在工作副本中。 For example: 例如:

svn rm dist --keep-local
svn ci -m'removed build directory from version control'

The directory will no longer be tracked by subversion but it will still be there in your working copy to hold compiler output, etc. subversion将不再跟踪该目录,但它仍然会在您的工作副本中保存编译器输出等。

cheers, joe 欢呼,乔

For example the folder structure: 例如文件夹结构:

Project/
Project/dist/

cd Project
svn propset svn:ignore '*' dist/
svn ci -m "content of dist ignored"

It's good to do a svn delete of dist content before the ignore command, so for branches dist will be empty. 在ignore命令之前对dist内容进行svn删除是很好的,因此对于branches dist将为空。

Worked for me, tested today. 为我工作,今天进行测试。 Here is the page explaining it a bit 这是一个解释它的页面

In order to ignore all such files in all repositories, you could add a global-ignores to your per-user configuration file. 为了忽略所有存储库中的所有此类文件,您可以向每用户配置文件添加global-ignores

On Unix-like systems, this area appears as a directory named .subversion in the user's home directory. 在类Unix系统上,此区域在用户的主目录中显示为名为.subversion的目录。 On Win32 systems, Subversion creates a folder named Subversion, typically inside the Application Data area of the user's profile directory 在Win32系统上,Subversion创建一个名为Subversion的文件夹,通常位于用户配置文件目录的Application Data区域内

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. 它基本上是每个用户或每个目录,所以多个svn:ignores可能是要走的路,尽管它很烦人。

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): 您首先必须移动到工作副本的顶级文件夹并在那里创建一个文件(例如.svnignore),您应该在其中放置您想要忽略的所有模式,例如(对于Android项目):

bin
gen
proguard
.classpath
.project
local.properties
Thumbs.db
*.apk
*.ap_
*.class
*.dex

Then you run the following command (remember that you must be at the top folder of your working copy): 然后运行以下命令(请记住,您必须位于工作副本的顶级文件夹中):

svn propset svn:ignore -R -F .svnignore .

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: 如果您希望开始被忽略的文件夹(或文件)也被忽略,请通过运行以下命令将其从版本控制中删除:

svn rm --keep-local <path>

Got all this from this great article that explains it all: http://superchlorine.com/2013/08/getting-svn-to-ignore-files-and-directories/ 从这篇解释一切的精彩文章中得到了所有这些: http//superchlorine.com/2013/08/getting-svn-to-ignore-files-and-directories/

In subversion 1.8 over, it is possible to set global-ignores for current repository. 在subversion 1.8 over中,可以为当前存储库设置global-ignores。

svn propset svn:global-ignores build .
svn propset svn:global-ignores dist .

Also you can create a folder named .svnignore, and write conditions. 您还可以创建名为.svnignore的文件夹,并编写条件。

build
dist

remember one condition per line, setting build/* or dist/debug is in vain. 记住每行一个条件,设置build / *或dist / debug是徒劳的。 Then do the command: 然后执行命令:

svn propset svn:global-ignores -F .svnignore .

Create a file and add your ignores into it 创建一个文件并将您的忽略添加到其中

ingore-list: 则会忽略列表:

file1 
directory1
file2
etc...

then apply the following command 然后应用以下命令

for n in directory; do svn propset svn:ignore -F ignore-list $n; done

directory is name of your directory, you can sub categorize as well directory/sub-directory. directory是您的目录的名称,您可以对目录/子目录进行子分类。 Or use * to note current directory you are under. 或者使用*来记录您所在的当前目录。

This is assuming you are using bash as your shell 这假设您使用bash作为shell

svn propset --recursive svn:ignore svn_ignore_rules .

where svn_ignore_rules is a file containing the ignore rules -- one per line 其中svn_ignore_rules是一个包含忽略规则的文件 - 每行一个

Of course you have to re-run it every time you add a new directory to your repo 当然,每次向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 svn_ignore_rules也可以被视为已检入仓库,可由具有对仓库的写入权限的其他用户重新使用

cd parent_dir #the directory containing folder to be ignored recursively
svn propedit svn:ignore . #will open up svn-prop.tmp
enlist folder(s)
^X
Y
commit -m 'ignore targeted direcoty'

一种方法是在提交前或提交后挂钩添加某种检查,但如果您不拥有repo服务器则直接注意。

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 use global-ignores which applies to a single user (but doesn't belong to the repository). 正如其他人已经明确的那样,您可以使用svn:ignore属性,这适用于单个目录(因此不适用于新目录),或者您使用适用于单个用户的global-ignores (但不属于到存储库)。

To make life a bit easier i created a reg file named Settings.Svn.reg and added it to the root of the repository. 为了让生活更轻松,我创建了一个名为Settings.Svn.reg的reg文件,并将其添加到存储库的根目录中。 Now everybody can doublecklick this regfile once, and has the settings done. 现在每个人都可以双击这个regfile一次,并完成设置。

REGEDIT4

[HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\miscellany]
"global-ignores"="obj *.suo *.bak *.pdb *.user *.Cache*"

I would really appreciate a solution within the SVN repository, so if somebody knows, would you care to share it? 我真的很感激SVN存储库中的解决方案,所以如果有人知道,你愿意分享吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM