Getting started with Subversion

Yesterday I was having a conversation with a recent convert to source control. He had a few questions and I thought the answers might be useful to other people. So here are the questions and answers with a bit of paraphrasing.

Q) I have just install visual SVN on my server and I am try to add all my sites to the repository. I do an import, then do a checkout to create the working copy over my original files, but it doesn't work, gives errors that the folders already exist.

I'm using Tortoise.

A) With Tortoise you'll need to delete or move the original files before you can check out the project into that location.

I was talking to a ColdFusion Developer so I asked if he was using Eclipse/CFEclipse. He is, so I pointed him at Subclipse and Subversive

Both of these are SVN plug-ins for Eclipse. Some people prefer Subversive over Subclipse. Personally I have no preference - I have a few different installs of eclipse and I'm using both in different places. You can't use both of them at the same time in the same client - its one or the other.

There are a number of immediate advantages to using one of these plug-ins.
The first one is that your svn client is integrated into your development environment, which makes your work flow easier. No need to go to an external client to check for updates or commit your changes and you can see there in your project which files you've changed recently.
Secondly,when you want to set up a development project in SVN, there is an option to "Share" your project. What this does is submits your project into your svn repo and also sets up your working copy as a "checked out".
Another advantage if you're using subversive, which helps with his first question/problem. If you have a project in svn and you have a project that already exists, subversive will ask you if you want to overwrite the existing project. This takes out the step of having to move or delete your existing working copy. (NOTE: Subclipse might do this as well - I just can't remember right now)

The next question was :

Q) So the eclipse plugin will commit my files every time I save?

A) I think you can tell it to do that, but I tend not to.

I would now like to retract this answer.... ;)
I've had a look at the docs for both subversive and subclipse and I can't see any way that you can do a "commit-on-save". Thinking about it I'm not sure you really want to be committing on every save anyway, unless you're doing something like extreme programming.

This lead on to :

Q) So what if you find out you messed up a file the last time you edited it and you didn't commit? Eclipse has some sort of basic rollback doesn't it?

A) There is local history built in to eclipse. From the right click menu, you can compare a file with a version in the local history or replace the file with a local history version.

I wanted to make sure that he was using svn in a way that would help him in the future as well as immediately, so I gave him this summary of how to use trunk, branches and tags. I know that this won't be the way that every one uses trunk, branches and tags, but this is one way that makes sense. So here's my summary :

Just a quick summary of tags and branches for you....
  • Trunk is pure development - new features - new version
  • Branches are live version which you should only do minor feature enhancements and bug fixes
  • Tags are fixed releases that are NEVER edited.

Q)So trunk is my working version. Branches would be like beta releases, and Tags would be final releases.

Say you have a released product at v1.01 and you're currently working on v2.
Trunk would be alpha/beta releases of v2
Branches you would have a branch called something like v100 which is a released version 1.00
In tags you'd have v100 which is the release at version 1.00, but you would also have v101 which is the released 1.01 version.

When you release v2 you'd copy it to a branch called v200 and create a tag called v200 - bug fixes for version 2 would now go into your v200 branch and version 3 development would occur in trunk.

The naming is up to you - the suggestions I used were just to give an idea of how to use branches and tags.

Well I hope that that is useful to someone else.

Guess the next logical step is to teach them how to create and apply a patch.
# Posted By Pragnesh Vaghela | 3/13/08 9:39 PM