bash 从所有目录中删除 .svn 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1301203/
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
Removing .svn files from all directories
提问by Mike2012
Possible Duplicate:
How do you remove Subversion control for a folder?
Command line to delete matching files and directories recursively
I recently converted my cvs repository to svn using cvs2svn and I recently noticed that every directory has a hidden folder called .svn. My current build script copies a lot of directories from my versioned resources directories and it ends up copying the .svn files. Is there anyway to make svn not include these files when I checkout or do I need to write a script to delete all these .svn files. There are many files that have these hidden .svn directories so this would be a pain unless I could write a recursive script to do this but I don't if I can do this for my windows installer. Is there an easy way to stop svn from putting this hidden directory everywhere in my project?
我最近使用 cvs2svn 将我的 cvs 存储库转换为 svn,我最近注意到每个目录都有一个名为 .svn 的隐藏文件夹。我当前的构建脚本从我的版本化资源目录中复制了很多目录,最终复制了 .svn 文件。无论如何让svn在我结帐时不包含这些文件,或者我是否需要编写脚本来删除所有这些.svn文件。有许多文件具有这些隐藏的 .svn 目录,因此除非我可以编写递归脚本来执行此操作,否则这将很痛苦,但如果我可以为我的 Windows 安装程序执行此操作,我就不会这样做。有没有一种简单的方法可以阻止 svn 在我的项目中随处放置这个隐藏目录?
采纳答案by mcintyre321
You can do a thing called an SVN Export to get the files without the .svn directories
你可以做一个叫做 SVN 导出的事情来获取没有 .svn 目录的文件
http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.export.html
http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.export.html
回答by Charles Finkel
I'm not sure in your specific case that you want to remove all those .svn directories. But if you do, here is a bash one-liner to do just that:
我不确定在您的特定情况下是否要删除所有这些 .svn 目录。但是如果你这样做了,这里有一个 bash one-liner 来做到这一点:
find . -name .svn -print0 | xargs -0 rm -r
回答by Nathan Taylor
I posted this yesterday over here, but here is again because I kind of put it in the wrong thread anyway...
我昨天在这里发了这个,但又发了一次,因为无论如何我都把它放在了错误的线程中......
I've got something that should make your day. Original source is here.
我有一些应该让你开心的东西。原始来源在这里。
This is a (perfectly safe) Shell Extension that will add "Delete SVN Folders" to your right click menu in Windows. Run it on any directory containing those pesky files.
这是一个(完全安全的)Shell 扩展,它将在 Windows 的右键菜单中添加“删除 SVN 文件夹”。在包含这些讨厌文件的任何目录上运行它。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""
To make this part of your build script copy that call to cmd.exe and execute it.
要使构建脚本的这一部分复制调用 cmd.exe 并执行它。
回答by Ralph
find . -name '.svn' -depth -exec rm -rf '{}' \; -ls
find . -name '.svn' -depth -exec rm -rf '{}' \; -ls
回答by Eric Perie
on Win32/Win64 systems, the following command should do the job:
在 Win32/Win64 系统上,以下命令应该可以完成这项工作:
del /q /s .svn
回答by crashmstr
Those folders are required for how subversion works with a working copy (i.e. where you've done a checkout).
这些文件夹是 subversion 如何使用工作副本(即您完成检出的地方)所必需的。
One option would be for you to do an export to another location. The export would not have the .svn folders, and you could run your script on that. Documentation: svn export, TortoiseSVN Export
一种选择是让您导出到另一个位置。导出不会有 .svn 文件夹,您可以在其上运行脚本。文档:svn 导出,TortoiseSVN 导出
Another option would be to modify your script to ignore hidden directories, or build a better build tool.
另一种选择是修改脚本以忽略隐藏目录,或构建更好的构建工具。
回答by Scott Weinstein
And a PowerShell version
和一个 PowerShell 版本
ls -Force -Recurse -Filter .svn | rm -Force -Recurse
回答by Fabiano Soriani
If wanna do this with ruby just paste my script at the root folder you want to remove recursively: http://fabianosoriani.wordpress.com/2009/03/19/ruby-script-to-remove-svn-folders/
如果想用 ruby 执行此操作,只需将我的脚本粘贴到要递归删除的根文件夹中:http: //fabianosoriani.wordpress.com/2009/03/19/ruby-script-to-remove-svn-folders/
回答by zombat
svn exportis what you want. It will give you a clean copy of the code tree without the .svn
directories (note that this copy is not under version control and svn commands won't work on it once it's exported).
svn export就是你想要的。它将为您提供一个没有.svn
目录的代码树的干净副本(请注意,此副本不受版本控制,一旦导出,svn 命令将无法对其进行处理)。
I utilize this method to launch code on production servers. Our build script takes an export of the code branch, tars and gzips it, uploads it to the correct server, and unzips/untars it.
我利用这种方法在生产服务器上启动代码。我们的构建脚本导出代码分支,对其进行 tar 和 gzip,上传到正确的服务器,然后解压/解压。
回答by ire_and_curses
You could take a look at SVK
, which is a layer on top of Subversion. One of the advantages is that the repository metadata for your working copy, which is normally stored in the .svn
dirs, is instead kept in a single central location, so you don't have the ugly hidden .svn
dir problem. It's pretty nice.
你可以看看SVK
,它是 Subversion 之上的一层。优点之一是您的工作副本的存储库元数据通常存储在.svn
目录中,而是保存在一个中央位置,因此您不会遇到丑陋的隐藏.svn
目录问题。这很不错。