Importing an existing Web site into Subversion
Last time, I played around with Subversion in order to determine just how Subversion worked.
This time I'm actually going to create a repository for a site to store the current version, and work through making a couple of updates.
Existing site structure
The site that I'll be working with is DoNotDenyMyUnicorn.com. It's a small, stable, site, that has just a few files. It's also relatively clean, with no previous versions floating about.
The directory for the site currently exists on another box, at C:\inetpub\wwwroot\donotdenymyunicorn\ and consists of 8 files in that directory.
-
index.html
-
main234x60.gif
-
print.css
-
robots.txt
-
screen.css
-
sitemap.xml
-
StrivingLifeGmail.png
-
(a Google-related file)
The new development structure
I won't be changing the structure of the site, but since I'll be moving the files to my Vista box, I'll have a slightly different structure.
First, I'll be storing the repository at B:\repos\DoNotDenyMyUnicorn\
You'll note that I'm using seperate repositories for each of my sites. However, I could create one repository for all my sites if I wanted to.
The development files will be stored at B:\projects\DoNotDenyMyUnicorn\
My workflow
Since I'm the only one working on my sites, I'll be keeping things simple. I'll do all my development work in B:\projects\ and push files once they've been tested and commited to the repository.
Depending upon what issues I run into, this may change, but this is what I'm planning for now.
Creating the repository
The first thing to do is create the repository we'll be using. The location of the repository will be B:\repos\DoNotDenyMyUnicorn\ , so the first thing to do is make sure that the directory exists. In my case, I need to create the DoNotDenyMyUnicorn folder.
With that done, I can right-click on the DoNotDenyMyUnicorn folder and select TortoiseSVN > Create repository here... (type of Native filesystem, of course).
Creating the working/development directory
Now that I've got the repository created, it's time to put data into it.
As I said before, the development directory will be at B:\projects\DoNotDenyMyUnicorn\ .
Now I have a couple of options. I can either import my existing content into Subversion, or I can create a working copy, add my data, and commit it.
In this case I'm going to create a working copy, since that makes more sense to me.
So, I right-click on the DoNotDenyMyUnicorn directory in B:\repos\ and select SVN Checkout...
I'll confirm that the URL is correct (file:///B:/repos/DoNotDenyMyUnicorn) and browse to the Checkout directory of B:\projects\DoNotDenyMyUnicorn .
Pressing OK, I've now got revision 0 in my projects directory.
Next I'll grab the eight files from my XP machine, and copy them into B:\projects\DoNotDenyMyUnicorn\ .
I can now either 'Add...' each of the files I want under version control, or just right-click in/on the DoNotDenyMyUnicorn directory to select SVN Commit...
Depending upon whether I already added the files, I may need to select the files I want added, but since I want them all, a simple check of "Select / deselect all" selects the eight files.
I'll type a meaningful message ("Initial check-in.") and press OK.
This should add the 8 files, and create revision 1.
If you don't see any TortoiseSVN status icons on the file icons, you may try refreshing Explorer with F5.
Making changes
Now there's just a few minor things that I want to change about the existing DoNotDenyMyUnicorn. I used Visual Studio 2008, but the editor doesn't really matter.
Once I've made my changes, I'll need to commit them to the repository.
Remember that if you have multiple developers, it's a good idea to see if any other updates have taken place since your last update.
This is as simple as either committing the changes by selecting, or by committing the entire project directory (DoNotDenyMyUnicorn, in B:\projects\) and letting SVN take care of the rest.
In my case I just had the one change.
Once I committed, I pushed the changed files up to my remote Windows server.
While doing so, I noticed that I had a favicon, that I didn't have on my devel site. Whoops.
It was easy enough to download that into my project directory, and add/commit that to the repository.
Conclusions
While this doesn't handle trunks, branches, tags, or any of that other fun stuff, for a simple Web site, as DoNotDenyMyUnicorn.com is, it's easy enough to move files into version control - much easier than I originally thought.
However, while we didn't talk about it, it's a very good idea to make sure that you have clean directories, without temp files, previous versions, and 'correct' directories. You can always exclude these from versioning, but a clean directory is a developer's favorite directory.
Next steps
My next steps are to move more of my sites into version control. Your next step should be to move one of your smaller sites, or test Subversion out.
Search
Links of Note
Support This Site
If my blog was helpful to you, then please consider visiting my Amazon Wishlist.