Problem:
You want to remove all the files in your subversion working copy but you do not want to remove the folder structure.
Description:
I have had to do this when upgrading an application from Rails 1.x to Rails 2.0. The file structure of my project changed significantly enough that I just moved everything out to a non-working copy to do the work. When I started to move the work back in there were a lot of files/folders that had changed.
Rather than work through the manual process of moving files in svn it's sometimes easier to just start from a new point in time within the same repository. In that case you want to:
- remove all the files in your current working copy yet preserve the folder structure for SVN
- move all the new files into your working copy and commit those changes
- clean up any new/missing files and folders.
Solution:
*nix
From the command line run:
find . -not \( -name '.svn' -type d -prune \) -type f -print | xargs rm
This says....
find from the current directory (find .)
...ignoring files in a directory called '.svn' (-not ( -name '.svn' -type d -prune ))
...any file (-type f)
...and delete it (-print lists the files and xargs rm removes any file in that list)
oddly enough the following _will_ list out the same as above...but -delete is invoked with -depth implied so you will end up deleting required svn files if you runfind . -type d -name '.svn' -prune -o -type f -printfind . -type d -name '.svn' -prune -o -type f -print
Windows
This is easier from the UI with your favorite search tool. I use Directory Opus so from the advanced tab specify Location to not match .svn and type matches files only.
Any other good ideas for this on Windows?
For Windows: Directory Opus has a good built-in find utility. A free alternative is Agent Ransack:
http://www.mythicsoft.com/agentransack/