views:

75

answers:

3

Hello,

I'm looking for some help in using svn with web development.

Here are my questions.

  1. I setup SVN on my webserver, but keep my project files on my PC untill I'm ready to "commit" them correct?

  2. How do I get the "pushed" files I've sent to the server in my directory such as /home/site/public_html/ .. basically I'd like to "commit - push" files straight to my web directory. Is this possible?

  3. I don't really understand the full concepts of how this can work for web development. I have read at least a dozen guides but none of them really outline step by step what I need to do.

A step by step guide for the above issues, or a kind response to manually help me out would be really appreciated.

running windows 7 @ home (what I'm developing on) running CentOS 5 server (live webserver)

Thanks for any help.

+1  A: 

First off, I recommend you download Tortoise. It is an integrated desktop client for SVN. You can use this to commit your files to your repository.

As far as process goes:

  • Do you local development on your PC
  • When ready, commit the files to the repository
  • After committing, update your copy on your webserver from the repository. You will probably have to do this via the command line. Here is a link to the SVN command line: http://svnbook.red-bean.com/en/1.0/ch09.html

You don't want to use SVN like an FTP client. It is meant to be a version control system. So, the repository is the one true, master copy of your data. What is on your webserver and your local machine are copies of that data. The reason for this is that you want to have one copy that you know is a good, working copy. SVN will allow you to revert the code base back to any point in time, so it also acts as an archive.

The above scenario assumes that you are able to test and validate that your code is working on your PC. Do you have a version of your webserver running on your PC?

Jeff Fohl
Yes, I have xampp running on localhost. Ty for the info btw, was very helpful.
Anon
A: 

you make your changes to your pages and do an svn commit on them to save those changes as a revision on the svn server. When you want to get a clean copy on the webserver do an svn export in the directory you want the files to be in. This is different from an svn checkout because it doesn't add all the .svn metadata files that svn uses in source control. This is also a downside because you need to export all the files every time. If you do an svn checkout in the directory all the metadata will be in the web directory too but you can easily remove them (with a script perhaps). This will allow you to just do an svn update in the web directory to pull all your future changes into the web directory.

controlfreak123
You might also want to write a script that automatically does the `svn export` and whatever else is necessary to get everything up and running. The export will still take just as long, but you can just start it and go worry about something else while it runs.
MatrixFrog
yes thats kind of what I was getting at. But the way I would do it would be to use a script that called svn update on a directory that isn't the web facing one but contains a checkout and then copies the files to the web directory. That way you only have to get the changed files and just copy the files you need to the web directory without all the metadata
controlfreak123
Thanks for the info so far, attempting to set all this up right now. :)
Anon
+2  A: 

When you say:

basically I'd like to "commit - push" files straight to my web directory. Is this possible?

It sounds like you want to commit your changes to the SVN repository, and have them automatically get pushed to the web server. If that's true, you can accomplish this by using the SVN post-commit hook. On your system, in the SVN repository directory, this is a subdirectory called "hooks". Edit the one called post-commit.bat and have it do an export to your web server, something like:

svn export <svn_repo> <webserver_location>
William Leara
+1 Yes - good catch. I forgot about the post-commit hook option.
Jeff Fohl
that is exactly what I was looking for, hats off to you sir.
Anon
@Anon - First, welcome to Stack Overflow! Be sure to upvote, and more importantly, ACCEPT (click the checkmark) the answer. Otherwise, you won't get good answers in the future.
Chris Thornton