
This article will attempt to explain what SVN is, and how to use it.
Table of contents
First of all, what is SVN?
Revisions
Working copy
What client to use?
Checkout
Update
Setting up a repository
Add; Commit
Email notifications
First of all, what is SVN? #
SVN stands for subversion. It’s a system similar to CVS. It’s basically a system used for developing software in a group. phpBB for example also uses it. The system maintains the files and all changes that are applied to them. There is a so-called “svn repository”, which hosted on a central server. Each developer installs an svn client that connects to that server. The server stores all files of the project, but it also stores all changes that are made to files. Like this it’s easy to see what has changed.
Revisions #
Subversion uses so-called revisions. A revision is the version of a file or a folder. Each time you change a file, the repository’s revision is incremented. Like this it is possible to identify each change by it’s revision.
Working copy #
When you checkout (explained later), you get a copy of the repository on your local machine. This copy is called “working copy”. This does not mean that it works, but rather that you’re supposed to work on it. Wwhen you’re done with your changes, you “submit” them to the server, and then they get added to/updated in the repository.
What client to use? #
There are different SVN clients out there. One good one for windows is TortoiseSVN, as it integrates nicely with explorer. A list of clients can be found here.
Checkout #
A checkout (as mentioned above) means connecting to the SVN repository through your client and downloading all files (usually of the latest revision, also called HEAD revision) to create a working copy. This is usually the first thing you do when using subversion. If you are using TortoiseSVN, create a new folder on your HD and right click it. Then choose “SVN Checkout”, and you will be prompted for an URL. Here you have to enter the URL to the SVN repository. As an example, let’s checkout a working copy for phpBB. Enter this as URL:
- Code: Select all
http://code.phpbb.com/svn/phpbb/trunk/phpBB
After this you should see SVN download the files. You should also (if using TortoiseSVN) see a green “check” symbol on every file’s icon. If you change a file, it will turn into a red “!” symbol for that file and the folder containing that file.
Update #
A repository gets updated from time to time. Every time somebody makes a change to it, the revision goes up. This means that our working copy is out of date, as soon as a developer commits something to the repository. What do we do now? Right click on the folder and choose “SVN Update”. Subversion will now automatically download the changes and update your files. If you changed them, it will attempt to merge the changes.
Setting up a repository #
Before continuing with the usage, I’d like to explain how to set up a repository, as the next part of the article requires this. Setting it up on an own server is too complex for this article. You can get free SVN at a few sites out there. I recommend either Sourceforge (Unlimited space) or Assembla (Private SVN). If you havn’t already, register at one of those sites and create a new project. Please only do this if you also intend to use them for that project you are working on. How to exactly set up SVN will differ from site to site, but you will find more in that site’s FAQ.
Add; Commit #
The commit, sometimes also referred to as checkin is the command that will allow us to send something to the repository. Assuming you set up an SVN repository and checked out a working copy (you need to enter your site username and password), go to this working copy. It’s empty, so let’s add something.
Create a new file, test.txt. Enter some text into the file. Now, let’s add it to our working copy. It is already in the working copy folder, but that doesn’t mean that it’s part of the working copy itself. Right click onto the file, choose “TortoiseSVN” » “Add”. Now your file should get added and receive a red symbol.
Now, the next step is the commit. We’ve added the file to our local copy, now we want to add it to the repository. So we right click onto the folder and choose “SVN Commit”. You should be prompted with a window, where you can select files for addition (so you don’t have to add them manually using right click), and you can enter a log message. It is suggested to always enter a log message, it will make sure you know what the commit was about later on. If you use a bug tracking system, you can also just enter that bug id.
Email notifications #
Most SVN providers have an option to send an email every time somebody commits. Like this you will get a diff per mail, each time somebody changes something.
