Submitted by Chris Tognela on Sat, 2005-12-24 01:27.
If you do any kind of development work, you will benefit from source control. This is something I've only recently discovered myself, literally about a week ago, and I'm reaping the rewards already!
What is Subversion?
Subversion is what's known as a version control system. Subversion aims to be the new-generation replacement for CVS. Version control systems remember every change ever made to files under their control.
Why use version control?
Version control allows developers to have local copies of a repository, allowing individual developers to work on their areas without having to worry about breaking the build for the rest of the team.
This is achieved by “checking out” a copy of the repository from the Subversion server, storing it on your local machine, and working from the local copy. When you've finished your work, you can “commit” the changes back to the repository, allowing other developers to update their local copy with your changes.
You also get the other advantages of being able to roll back bad changes, create automatic build systems using “hook” scripts, as well as looking at file histories and the differences between files.
Moving forward, here's how I set up Subversion for my team.
On Debian, to install Subversion, I typed this:
That caused apt-get to happily download and install the Subversion packages. I already had SSH, so if you don't have that, grab it now.
The next step was to create a place for the repository. This can be pretty much anywhere you like. I chose to use /opt/svn:
Then you create the repository:
If you do an
Then change the owner and group of /opt/svn to svn:
Finally, change the permissions to allow owner and group access only:
I ran into some problems here, but a quick query on the AYT Forums sorted it out. The 2 in the chmod is used to set GID, which means that new files will be owned by the user and the group instead of solely being owned the creator of the file.
That's basically it! You have a repository that developers can use for code control.
Setting Up TortoiseSVN
TortoiseSVN is a superb Windows client that integrates right into the Explorer shell. You can download an msi package from here.
After installing the package, reboot your machine. When you're back up, right click in an Explorer window, and you'll see the TortoiseSVN menus.
First, create a new folder wherever you like and call it whatever you want. This will be for your local copy of the repository.
Next, right-click the folder you just created, and select SVN Checkout. In the dialog box, in the URL field, type the following and click OK:
svn+ssh is how TortoiseSVN access your server, email@example.com is your credentials for logging in, and /opt/svn is where the repository is located on the server.
If all goes well, you should get a password prompt. Type in your password – you might have to do this a few times. If all goes well, the dialog box should say Completed and At revision 0.
To test this, create a new text file inside the local repository. Right click inside the folder and select TortoiseSVN > Add. A box pops up listing your new text file. Click OK and you'll get confirmation that the file was added. Close that box and right click again, this time selecting SVN Commit. Again you'll get a list of files to be committed. Click OK, enter your password a few times and you'll get confirmation again. That's it, you've successfully used Subversion!
Excellent documentation is available for further reading using the free Subversion book, available at http://svnbook.red-bean.com/
In the next article, I'll show how to fix the password prompts so you don't drive your coders batty.