I've experimented a little with version control over the years (cvs, svn) but never used it in anger even though I know I should.
The thing that's always stopped me is that I've never found one that I've liked for web development.
What I have is a server in my office that everything gets developed on. When I am happy, I use unison to synchronise the changes to the live site. What this gives me, is no ability to roll back changes if something goes wrong.
What I want is for the version on the live site to just be a checked out version from a version control system, with the changes on the dev server being checked in to the version control as we develop. However, to me the logical location for the version control system is therefore my dev server in the office (which has plenty of disk space), but I don't want to open up ports to allow live servers to "pull" a version from the system. I want to be able to "push" a version to the server from the dev server, and that's where I get stuck.
The best solution I've ever come up with is to check out a separate local copy which I then unison to the live site, but this is two steps instead of one and (more importantly) means duplicating the site locally for no real benefit - which is a pain if a site has several hundred MB of images, for example.
The other part that I've never found a good solution for is handling databases; ideally there should be a way to perform diffs against different MySQL database schemas and apply them but I'm not aware of a way to do this either.
On the other hand, what I want to do seems like a fairly "standard" thing so I'm sure either there must be a way or that other people in similar situations have found a better way to do it than I am suggesting?
Mark Rogers wrote:
However, to me the logical location for the version control system is therefore my dev server in the office (which has plenty of disk space), but I don't want to open up ports to allow live servers to "pull" a version from the system. I want to be able to "push" a version to the server from the dev server, and that's where I get stuck.
I suggest using Mercurial or Git rather than a cvs/svn which are limited to a centralised model. Then you can have a repository on your dev machine, and clone it to your production machines. Check in changes on your dev machine, push them to the remote repository, then do whatever your chosen vcs needs to update your working copy there (which you can probable automate), and do whatever your server needs to deploy/restart (if anything).
This has the advantage that if your dev machine dies, you can make changes (or roll back) on your production server, and later pull them back to your dev machine.
A good place to start with Mercurial is: http://hgbook.red-bean.com/read/a-tour-of-mercurial-the-basics.html The short version for your usecase is:
dev$ hg init siteX dev$ cd siteX dev$ # copy your files to this directory dev$ hg add dev$ hg commit -m 'Initial commit' dev$ hg clone . ssh://user@prod/siteX
prod$ cd siteX prod$ hg update
dev$ # make changes dev$ hg commit -m 'cool new stuff' dev$ hg push ssh://user@prod/siteX
prod$ hg update
You can configure mercurial so you don't have to type the remote url to push, see http://mercurial.selenic.com/wiki/TipsAndTricks 2 You can automate that "hg update" on the remote server, see http://mercurial.selenic.com/wiki/FAQ 4.19
So then you just commit and push.
-- Martijn