10

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?

coredump
  • 12,573
  • 2
  • 34
  • 53
siliconpi
  • 1,707
  • 6
  • 30
  • 45

5 Answers5

21

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.

coredump
  • 12,573
  • 2
  • 34
  • 53
4

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

pragnesh
  • 492
  • 2
  • 5
3

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

gsreynolds
  • 448
  • 3
  • 10
  • 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 02 '11 at 01: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 02 '11 at 01:21
2

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.

ekerner
  • 140
  • 5
  • @kerner - how do you update them then? – siliconpi May 02 '11 at 00:11
  • 1
    Why not just use `svn export` and not bother filtering them? – pjmorse May 02 '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 07 '11 at 17:04
1

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.

dhasenan
  • 111
  • 1