Subversion and Web Design
I’ve started using Subversion for all sites that I’m developing. If I’m lucky, the target host has subversion installed and it makes site deployment and updating really easy. If not I can always grab a clean copy out of the repository to upload via sFTP. Either way I have a versioned back-up of the site on a remote server.
So, first I create a repository. There is an import feature to svn but I usually just create an empty one even if there is an existing site. I do this through my host’s control panel. Then I check out the empty repository to my local working directory:
cd ~Sites/domain.tld
svn co http://mydomain.tld/svn/path/to/repos ./
If a site exists I copy the files into the working directory and then add them to the repository:
svn add filename
orsvn add foldername
I use TextMate to write my code and it has a pretty nice svn bundle that lets you add, delete and commit changes to the repository with keyboard shortcuts (⌃-⇧-A brings up svn commands with number keys to execute) right in TM. But sticking with the command line for the moment, I commit files to the repository:svn ci -m “commit message”
You can delete superseded files from the repository too.svn del filename
or
svn del foldername —-force
My host makes sub-domains really easy, so I just ssh into the appropriate sub-directory of the domain I’m working on and then check out a copy of the site. From then on I can update it just by ssh-ing to that dir and running and update:svn up
I deploy to the final site the same way. It makes incremental development and upgrades easy. I just update the development subdirectory for the client to look at and then when they’ve approved it I update the main site. Svn does have an export feature that will deposit just the latest version of the site without all the older versions squirreled away. But unless your site is really old with lots of version or lots of big files, I don’t think it will hurt to do it the update way.I find that it works well for me even though I’m a one-man-shop. I imagine that it would be even more advantageous in the collaborative environment that svn was designed for.
You can find out more about what svn can do with the free online manual.
