转载:http://blog.csdn.net/solitonor/archive/2008/05/02/2358312.aspx
很多时候,需要删除SVN工作目录下的.svn目录,常用的作法是用系统(Windows)自带的搜索功能,搜索出所有.svn目录(需要在“其 他高级选项”中选中“搜索隐藏的文件和文件夹”),然后全选删除。这当然不是高效的作法,谁能忍受一遍又一遍重复这种纯体力的劳动?
Jon Galloway提供了一段注册表代码,可以将”Delete SVN Folders”命名增加到资源管理器的右键上,这样,鼠标点两下就能把选中目录下的所有.svn目录干掉了。Works just great!
代码为:
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/" /""将这段代码保存为一个.reg文件,双击确认导入注册表即可。
出自: Jon Galloway : Shell Command - Remove SVN Folders
在类unix系统上可以使用如下shell脚本:
#!/bin/sh
echo "recursively removing .svn folders from"
pwd
rm -rf `find . -type d -name .svn`
参考:http://www.anyexample.com/linux_bsd/bash/recursively_delete__svn_directories.xml
运用: 对于一个svn管理的项目,可以把如下代码保存脚本,放在项目的根目录下:
#!/bin/sh
unset backup
backup=0
unset remove
remove=0
printf 'Do you want to back up the current folder? (y/n/q): '
read yn
case $yn in
y | Y)
backup=1
;;
n | N)
continue
;;
q | Q)
exit 1
;;
*)
echo ""
echo "Please enter 'y', 'n', or 'q'."
;;
esac
## backup
if [ backup ];then
SUFFIX=_bak
CWD=$...{PWD##*/}
mkdir ../$CWD$SUFFIX
cp -rf * ../$CWD$SUFFIX
echo done!
fi
printf 'Do you want to clean the svn hidden folders? (y/n/q): '
read yn
case $yn in
y | Y)
remove=1
;;
n | N)
continue
;;
q | Q)
exit 1
;;
*)
echo ""
echo "Please enter 'y', 'n', or 'q'."
;;
esac
if [ remove ];then
echo ""
echo "recursively removing .svn folders from"
pwd
rm -rf `find . -type d -name .svn`
echo ""
echo done!
fi
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/solitonor/archive/2008/05/02/2358312.aspx