21

I am using SVN while developing a WordPress site. Now I want to upload it to the server and there are loads of SVN files in .svn folders. Are these safe to remove and how do I remove them?

3

7 Answers 7

48
find -type d -name .svn|xargs rm -rf
3
  • 2
    Thank you for answering the interesting part of the question.
    – Scott C
    Dec 30, 2011 at 7:43
  • 3
    On mac osx you have to change up this command a bit. try this ... find ./ -name ".svn" | xargs rm -Rf Mar 19, 2013 at 16:47
  • 1
    in the newly released svn 1.8, there is only a single .svn directory at the top level.
    – thekbb
    Jul 1, 2013 at 22:19
34

You may also find the svn export command useful. This command exports a copy of your working tree without the .svn folders.

This comes pretty handy if you develop under the Subversion recommended tagging way, you can always export a tag, and then you'll have a better control over what revision is on production.

3
  • mod +1: Use svn export and create a clean copy for your wordpress site in another directory. If you remove the .svn folders, you can't update or use your workspace anymore. Thus, force to do a new svn checkout anyway.
    – David W.
    Jun 3, 2011 at 17:11
  • additionally you can export only the last updated files spanning only the commits you need, very useful. Another thing I like to do, in CuteFTP, I set a mask so that CuteFTP will not upload .svn folders, useful when I do quick drag and drop uploads, bypassing export.
    – farinspace
    Jun 18, 2011 at 19:00
  • Note that svn export won't follow any symlinks that may exist in the repo, but will copy the symlink themselves over to the destination (which doesn't work well with relative symlinks..). Jun 8, 2012 at 10:10
5

If you want to delete all sub folders named .svn then create batch file with this content:

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. Your done.

Thanks to 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.

4

If you're going to remove these directories, you will probably get troubles with your svn client. As a result, you have to do a new checkout of your repository.

Instead of removing these directories, you could exclude these from uploading with a filter inside your FTP program. I'm using Trasmit 4, which has support for this kind of functionality.

2
  • Thanks for the answers, the FTP exclude seems handy, will check if there is something for FileZilla.
    – drtanz
    Jun 3, 2011 at 12:42
  • Should be possible. Checkout the following FileZilla Wiki
    – Roman
    Jun 3, 2011 at 12:55
2

Perhaps exporting the folder is a better solution in your case. Exporting, excludes the .svn folders. If not, in mac/linux go to your terminal and type these:

cd /your/directory
find . -iname ".svn" -print0 | xargs -0 rm -r
1

Your SVN checkout directory should always keep the .svn directories; that's how it communicates with SVN.

But any copies of your checked-out files - e.g. for packaging/uploading - can safely remove the .svn directories. They don't need the SVN-checkout data. To remove the .svn directories from these copies, simply delete them. (And see @Fernando's answer regarding svn export.)

0

you just have to use the export-function from SVN and export your folder in itself and it will remove the .svn folder and uncouple it from the version control.

Reference: http://tortoisesvn.net/unversion.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.