tags:

views:

336

answers:

7

Currently I have subversion set up so that when I make changes in Eclipse PDT, I can commit the changes and they will be saved in /home/administrator/Project File. This file has the /branches /tags and /trunk directories recommended by subversion. I have no problem properly uploading files to the repository, but do I have to "mv" the files in Linux to /var/www in order to make them live on the server? Is there an automatic process to do this that I am missing? I'm assuming we don't want to make the /var/www directory (which is live on the machine) the repository, but I don't know.

+6  A: 

You can do an svn export into your www directory. That will give you a "clean" version of your repo, without the .svn directories.

cd /var/www
svn export /home/administrator/MyProject/trunk MyProject


Edit: adding in some good ideas from the comments...

Some options for when you want to update your exported copy:

  • run svn export --force /home/...../ MyProject this will stop it complaining about overwriting the existing files. This method will mean that if you delete a file from your repository, it'll still remain in your www folder.
  • change your SVN command to export into a new directory each time:
    svn export /home/..../ MyProject_20081105
    and then create a symlink to that folder:
    ln -s MyProject_20081105 MyProject
    Just delete and recreate the symlink each time you "release". In this case, the export directory doesn't need to be in the www folder at all.
nickf
Wow, that is simple! And I probably would have just moved the whole directory manually in Linux everytime and copied over the .svn directories. Thanks for the help!
Matt
If this is recurring, should probably add '--force' to the export so it doesn't complain that the files already exist.
Jonathan Lonowski
It's a good idea to export into a new directory and then have the www-root be a symlink. Once the export is done, update the symlink to point to the new dir and delete the old one.
troelskn
+1  A: 

You can simply check out a copy of the repository in the /var/www folder, and then run svn update on it whenever you require (or switch it to a new branch/tag, etc). Thus you have one copy of the respository checked out on your local machine where you make changes and updates, and another copy on your webserver.

Using an SVN repository also gives you the ability to revert to earlier versions as well.

JamShady
+1  A: 

You can also make a post-commit hook that moves all the files changed by the commit to the /var/www directory.

Here is an example written in python that uploads the changed files to a remote host via ftp:

http://svn.haxx.se/dev/archive-2007-08/0287.shtml

Davide Gualano
A: 

You'll probably want to remember what files you have on production at any given time - so keep a "release" tag (e.g. in /project/tags/release). When you want to make a release, copy your trunk into there. Then svn export that release tag.

Or something.

MarkR
A: 

I've seen many people on here and other forums talk about using Capistrano for deployment, but I don't have any personal experience with it.

Peter Bailey
A: 

In my organization we use rsync to move files from a dev environment to production.

Michael Luton
A: 

I agree with Michael. rsync is the tool to use.

*Why* is rsync a better tool to use? You can hide .svn files (through your web server or via file permissions) + you get the benefit of being able to update and rollback to specific versions. What does rsync give you?
Avry