递归删除 Windows 上所有 .svn 目录的命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4889619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Command to recursively remove all .svn directories on Windows
提问by user489041
I have a directory with many sub-directories. In each folder there is a subversion folder (.svn).
我有一个包含许多子目录的目录。在每个文件夹中都有一个 subversion 文件夹 (.svn)。
Is there a command in windows that will go through each folder and sub-directory and delete the .svn folder?
windows中是否有一个命令可以遍历每个文件夹和子目录并删除.svn文件夹?
Or will I have to create a script or do it manually?
或者我必须创建一个脚本还是手动完成?
采纳答案by Greg Hewgill
Use the svn export
command to export a Subversion working copy into a new "clean" directory structure that doesn't have the .svn
directories.
使用该svn export
命令将 Subversion 工作副本导出到没有目录的新“干净”目录结构中.svn
。
回答by Ajit Vaze
Make a litte batch file with the following line and execute it from the parent folder under which there are .svn directories.
使用以下行制作一个小批处理文件,并从有 .svn 目录的父文件夹中执行它。
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G"
You can also issue the line below straight from the Command Prompt:
您还可以直接从命令提示符发出以下行:
FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%G"
回答by Bobby Cannon
Do this in PowerShell.
在 PowerShell 中执行此操作。
NOTE:This is recursive so be sure you are in the right directory!
注意:这是递归的,因此请确保您位于正确的目录中!
gci -fil '.svn' -r -force | ri -r -force
Here is the rest of my source tree cleanup script.
这是我的源代码树清理脚本的其余部分。
gci -fil 'bin' -r -force | ri -r -force
gci -fil 'obj' -r -force | ri -r -force
gci -fil '_ReSharper*' -r -force | ri -r -force
gci -fil '*.suo' -r -force | ri -r -force
gci -fil '*.user' -r -force | ri -r -force
回答by visar_uruqi
If you want to delete all sub folders named .svnin windows then create batch file with this content:
如果要删除Windows 中名为.svn 的所有子文件夹,请使用以下内容创建批处理文件:
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (
rd /s /q "%%i"
)
save it in a file del_All_Dot_SVN_Folders.cmd. Run it. You're done.
将其保存在文件del_All_Dot_SVN_Folders.cmd 中。运行。你完成了。
Thanks to http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/
感谢http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/
Remember the above code has .svn whereas the code in the link has only *svn so its better to have the .svn to not accidentally have undesired effect.
记住上面的代码有 .svn 而链接中的代码只有 *svn 所以最好有 .svn 以免意外产生不良影响。
回答by Roland
Just type .svn in the search box of the File Explorer, then select and delete all search results (see JB Nizet's comment). This method can of course also be used to quickly delete the obj and bin directories, e.g. when organizing svn archives.
只需在文件资源管理器的搜索框中键入 .svn,然后选择并删除所有搜索结果(参见 JB Nizet 的评论)。这种方法当然也可以用于快速删除 obj 和 bin 目录,例如在组织 svn 档案时。
Although OP asked for a commandline solution, he also indicated using Windows, and considered a manual deletion, so the File Explorer method could still be considered, especially because it is the fastest method and does not rely on 'tools' like svn export.
虽然OP要求提供命令行解决方案,但他也表示使用Windows,并考虑手动删除,因此仍然可以考虑使用文件资源管理器方法,特别是因为它是最快的方法,并且不依赖svn export之类的“工具”。
Although OP already selected an accepted answer, this answer might still be useful for others. At least it was useful for me, a long time linux / windows user who prefers command lines and first learned about the search box by this post :-)
尽管 OP 已经选择了一个可接受的答案,但此答案可能对其他人仍然有用。至少它对我很有用,我是一个喜欢命令行并首先通过这篇文章了解搜索框的长期 linux/windows 用户:-)
回答by fresh learner
I know its too late to answer this but i guess there is an easy way IF have eclipse and the svn plugin installed on your eclipse. Right click on the project, go to Team->disconnect. It will open a popup where you select the first option: 'Also delete the SVN meta-information from file system.' This will remove all the SVN folders automatically along with svn property files that you might forget sometimes while removing .svn folders only!
我知道现在回答这个为时已晚,但我想如果在您的 eclipse 上安装了 eclipse 和 svn 插件,有一种简单的方法。右键单击项目,转到 Team->disconnect。它将打开一个弹出窗口,您可以在其中选择第一个选项:“同时从文件系统中删除 SVN 元信息”。这将自动删除所有 SVN 文件夹以及 svn 属性文件,您有时可能会在仅删除 .svn 文件夹时忘记这些文件!
回答by fatihk
As an important point, if you want to run shellto delete .svn folders, you may need -depthargument to prevent find command entering the directory that was just deleted and showing silly error messages like e.g.
重要的一点,如果你想运行shell来删除 .svn 文件夹,你可能需要-depth参数来防止 find 命令进入刚刚删除的目录并显示愚蠢的错误消息,例如
"find: ./.svn: No such file or directory"
To get rid of this error, you can use the find command as the following:
要摆脱此错误,您可以使用 find 命令,如下所示:
cd [dir_to_delete_svn_folders]
find . -depth -name .svn -exec rm -fr {} \;