如何从 svn 存储库中批量删除文件/目录 [英] How to batch delete files/directories from svn repository

查看:28
本文介绍了如何从 svn 存储库中批量删除文件/目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用:VisualSVN 服务器、TortoiseSVN、AnkhSVN

我使用 TortoiseSVN 为我所有的 .NET 项目和我想要保留的支持源/资源加载了初始存储库.

I used TortoiseSVN to make an initial repository load for all my .NEt projects AND supporting sources / resources that i want to keep.

我计划将 tortoiseSVN 用于所有常规源代码控制操作,并将 AnkhSVN 用于 Visual Studio 解决方案.

I am planning to use tortoiseSVN for all general source control actions and AnkhSVN for within Visual Studio solutions.

我的问题是我的存储库现在有我不需要的开发人员/机器特定文件/目录.

My problem is that my repository now has the developer/machine specific files/directories that i dont need.

我知道 Ankhsvn 通过使用 Microsoft 的 SCC API 不包括它们,如果您从 Visual Studio 中将解决方案添加到存储库.

I know Ankhsvn by using the SCC API from Microsoft does not include them if you add the solution to the repository from within Visual Studio.

所以我现在需要的是从 svn 存储库中批量删除必要的文件/目录.

So what i need now is to go and batch delete the necessary files/directories from the svn repository.

这些包括(但我可能会添加更多):

These include (but i may add more):

thumbs.db Thumbs.db *.bak *.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk *.msi* .res *.pch *.suo *.exp *.*~ *.~* ~*.* cvs CVS .CVS .cvs release Release debug Debug ignore Ignore bin Bin obj Obj Generated Logs *.csproj.user *.user

如果不一一进行,我该怎么做?

How can i do it without of course going one by one?

附加信息:

Micha 提出了一个想法 此处 但必须在移动到存储库之前进行.

One idea is what Micha has proposed HERE but that must occur before moving to the repository.

推荐答案

我总是建议开发人员在使用 VisualStudio 项目时使用 AnkhSVN 而不要使用 TortoiseSVN.AnkhSVN 不允许您将私人用户文件签入您的 VIsualStudio 项目.

I always recommend to developers to use AnkhSVN and not to use TortoiseSVN when using VisualStudio projects. AnkhSVN will not allow you to check in private user files into your VIsualStudio project.

要删除这些文件,您必须检出存储库才能删除单个文件.现在有办法解决这个问题.对不起...

To get rid of these files, you will have to checkout the repositories in order to delete individual files. There's now way to get around that. Sorry...

首先,您需要一个 VisualStudio 文件列表不应在您的 Subversion 存储库中.

First you need a list of the VisualStudio files that shouldn't be in your Subversion repository.

然后,您应该获得 Subversion 客户端的 Windows 命令行版本.您可以从 SlikSVN 获取此信息.基于命令行的 Subverison 客户端将允许您以编程方式删除不需要的文件,而无需一次一个.

Then, you should get a Windows command line version of the Subversion client. You can get this from SlikSVN. A command line based Subverison client will allow you to programatically remove the unwanted files without going after them one at a time.

例如,如果您使用 Cygwin 在您的 Windows 系统上提供类似 GNU/Linux 的环境,您可以做这样的事情:

For example, if you use Cygwin which provides a GNU/Linux-like environment on your Windows system, you could do something like this:

$ svn checkout $repo-project $workdir
$ find $workdir \( -name "*.suo" -o -name "*.csproj.user" \) -exec svn delete {} \;
$ svn commit -m"Removing all VisualStudio private files from repo" $workdir

或者您可以编写一个简短的 Perl、Python 甚至 PowerShell 程序来为您执行此操作.

Or you can write a short Perl, Python, or even PowerShell program to do this for you.

如果您不了解 PowerShell,这可能是您在 PowerShell 中进行的第一个不错的项目.自 XP 以来的所有 Windows 版本都带有 PowerShell.PowerShell 是一种非常强大的脚本语言——比 Windows Batch 强大得多,甚至比 Bash shell 脚本更强大.哎呀,它在脚本编写能力方面相当于 Python 或 Perl.我只是不明白为什么在基于 Windows 的开发站点中很少使用它.但是,如果您确实学习了它,您会发现它是处理各种 Windowy 内容的强大工具.PowerShell 与 Windows 注册表、IIS 和各种系统服务集成.

If you don't know PowerShell, it might be a nice first project to do in PowerShell. All versions of Windows since XP come with PowerShelL. PowerShell is a very powerful scripting language -- vastly more powerful than Windows Batch, and even more powerful than Bash shell scripting. Heck, it's the equivalent of Python or Perl in scripting prowess. I simply don't understand why it's so rarely used in Windows-based development sites. However, if you do learn it, you'll find it a powerful tool for all sorts of Windowy stuff. PowerShell integrates with Windows registry, IIS, and all sorts of System Services.

一旦你删除了所有这些用户文件,你就可以使用这个 Subversion pre-commit 将它们永远保留在您的 Subversion 存储库之外.控制文件条目将是这样的:

Once you've deleted all of these user files, you can use this Subversion pre-commit to keep them out of your Subversion repository forever. The control file entry would be something like this:

[FILE You cannot add private user files into a VisualStudio project]
match = VSproject/.*/\.(suo|user|webinfo|dll|exe)$
access = no-add
users = @ALL

这篇关于如何从 svn 存储库中批量删除文件/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆