简体   繁体   English

SVN 递归删除和忽略

[英]SVN Delete and Ignore recursively

I have a repository with some files ending in .scc我有一个存储库,其中一些文件以.scc结尾

There is one of these files in just about every subfolder of the repo and they are all committed.几乎在 repo 的每个子文件夹中都有这些文件之一,并且它们都已提交。

I'm using:我正在使用:
TortoiseSVN 1.6.15, Build 21042 - 64 Bit TortoiseSVN 1.6.15,内部版本 21042 - 64 位
Subversion 1.6.16颠覆 1.6.16

With TortoiseSVN I can go into each folder and right-click on the file and select " Delete and add to ignore list " but that's a pain to do that in each and every folder.使用 TortoiseSVN,我可以进入每个文件夹并右键单击该文件并选择“删除并添加到忽略列表”,但是在每个文件夹中都这样做很痛苦。 So I am basically looking for an easy way to recursively do exactly the same as TortoiseSVN's "Delete and add to ignore list".所以我基本上是在寻找一种简单的方法来递归地执行与 TortoiseSVN 的“删除并添加到忽略列表”完全相同的操作。 Either through TortoiseSVN or the command line.通过 TortoiseSVN 或命令行。

To add a file to the ignore list , you can update your %USERPROFILE%\\local data\\.subversion\\config file.要将文件添加到忽略列表,您可以更新%USERPROFILE%\\local data\\.subversion\\config文件。 (I'm not 100% sure where it's located, but it should be under the .subversion directory somewhere under your %USERPROFILE% directory. Unix and Macs, it would be under $HOME/.subversion/config . (我不是 100% 确定它的位置,但它应该在 %USERPROFILE% 目录下的.subversion目录下。Unix 和 Macs,它应该在$HOME/.subversion/config

In that file, there's a global-ignores= parameter.在该文件中,有一个global-ignores=参数。 You can remove the # in the front of it (if it's not already removed), and add .ssc to it.您可以删除它前面的# (如果它尚未删除),然后添加.ssc到它。 It's around like #90 in my version of this file.在我的这个文件版本中,它大约是#90。

Now, you'll have to figure out a way to delete all of these .scc files.现在,您必须想办法删除所有这些.scc文件。 All you have to do is this:你所要做的就是:

  $ find . -name `*.scc -exec svn del {} \;`

Wait, you're using Windows.等等,你正在使用 Windows。 That's harder.那更难。 I don't have a Windows machine in front of me, but I know you can find all of thes *.scc files by doing this:我面前没有 Windows 机器,但我知道您可以通过执行以下操作找到所有这些*.scc文件:

 C:> dir *.scc /s/b

You might be able to pipe this into a for loop of some sort, and pass it to a svn del statement.您可以将其通过管道传输到某种形式的for循环中,并将其传递给svn del语句。 Even if I had a Windows machine, it can take me a while to work out the syntax.即使我有一台 Windows 机器,我也可能需要一段时间来计算语法。 Since I don't have a Windows machine in front of me, it's even more difficult.由于我面前没有Windows机器,所以更难。

Easiest way would be to redirect the output to a file, and then edit the file using a good program editor (by which I mean not notepad.exe ):最简单的方法是将输出重定向到一个文件,然后使用一个好的程序编辑器编辑该文件(我的意思不是notepad.exe ):

 C:> dir *.scc /s/b > delete_me.bat
 C:> notpadplusplus delete_me.bat

Now, you can use Notepad++ to edit your file and quickly prefix each line with a svn del .现在,您可以使用Notepad++来编辑您的文件,并使用svn del快速为每一行添加前缀。 Run this delete_me.bat file, and it will remove all of your *.scc files.运行此delete_me.bat文件,它将删除所有*.scc文件。 (I personally prefer Vim , but then I'm a masochist). (我个人更喜欢Vim ,但后来我是一个受虐狂)。

The big question is how to prevent adding these files back.最大的问题是如何防止重新添加这些文件。 Ignores set up as I showed you are client specific.忽略设置,因为我向您展示了特定于客户的内容。 You could setup a svn:ignore property in each directory.您可以在每个目录中设置一个svn:ignore属性。 This is a more global version that affects everyone, but it still won't prevent someone from adding them because the files will still show up in Windows Explorer.这是一个影响所有人的更全局版本,但它仍然不会阻止某人添加它们,因为文件仍会显示在 Windows 资源管理器中。

I have a pre-commit hook that can be setup, so no one will ever be able to add in these .scc files again.我有一个可以设置的预提交钩子,所以没有人能够再次添加这些.scc文件。 You could also set it up not to include the other types of files that VisualStudio puts in too.您还可以将其设置为不包含 VisualStudio 放入的其他类型的文件

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

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