Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm doing svn update to update the code for my php website, but it leaves .svn/ folders all over.

I think its dangerous to leave those files publically readable, but its very easy to update the system.

Is there a way to use svn update to update the system, but not to export the .svn/ folders?

share|improve this question

5 Answers 5

up vote 20 down vote accepted

If you are using apache:

<Directory ~ "\.svn">
    Order allow,deny
    Deny from all
</Directory>

That will block people from accessing .svn directories remotely (using the browser) but you can keep then (and svn capabilities) on the project.

BTW you can substitute \.svn for \.git or \.cvs if you are using something different than subversion.

share|improve this answer
    
and this will block all .svn directories across the website? i have many subdirectories –  siliconpi May 1 '11 at 13:14
    
currently my httpd.conf has <Directory /> Options FollowSymLinks AllowOverride All </Directory> can i add what you wrote just below this as a separate thing or do the two entries need to be merged? –  siliconpi May 1 '11 at 13:15
    
It will match any directory called .svn so yes. –  coredump May 1 '11 at 13:16
    
You can add it separately. –  coredump May 1 '11 at 13:16
    
much better solution! thank you @coredump! –  siliconpi May 1 '11 at 15:10

you should change apache configuration so that it denies acess to .svn folder. this thread has more info http://stackoverflow.com/questions/398008/deny-access-to-svn-folders-on-apache

share|improve this answer

You are wanting to export your code from the SVN to the live site...

Don't use svn update for that. update is meant for use with updating working copies, not exporting the code. Use svn export instead as it exports a clean directory tree from the repository specified.

The --force flag will allow the export to overwrite the existing files.

SVN Export manual entry

share|improve this answer
    
I can sympathise if the OP doesn't want to use export, as it involves always grabbing a whole fresh new copy of the repository, which is a hassle if it's a large repo on a small connection (say the web server a hosted server, but your SVN repo is in your local office and shared by a 1Mb link). update means that you don't need to get the whole thing every time. –  Mark Henderson May 2 '11 at 1:03
    
A fair point. Perhaps exporting to a local copy of the site, then just rsyncing the changes across to the remote webserver would work in that situation? I've never had that problem so I hadn't considered it. –  gsreynolds May 2 '11 at 1:21

I dont put them into production/live sites. Coz I dont want me and/or other developers forgetting what a bad idea it is to edit live code. My install script filters my .svn files out.

share|improve this answer
    
@kerner - how do you update them then? –  siliconpi May 2 '11 at 0:11
1  
Why not just use svn export and not bother filtering them? –  pjmorse May 2 '11 at 15:26
    
I have an install script that I use for my sites, and tweak slightly to suit each. It usually also does stuff like build the databases, db tables, and db users, setup any default users or admins, etc. So to do an export to prod, the prod user (as a human or a script) checks out an svn working copy to somewhere along ~/ , and then runs the install script which is a member of the said working copy, then optionally deletes the working copy. –  ekerner May 7 '11 at 17:04

You should look into a proper deployment system, such as Capistrano. This means your production servers don't need subversion, and you can deploy to multiple servers and add custom logic to deployments. It also makes it relatively easy to roll back deployments.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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