In my last post I explained how version control works, today I'll explain how to create your first local subversion repository using the tortoiseSVN subversion client.
There are several ways to have a Subversion repository, you can create an open source application and host in Google Project Hosting, you can sign up for a professional subversion hosting like wush.net, and you can keep it simple (stupid), and create your own local subversion repository.
A repository is basically the main subversion database where subversion tracks all modifications you do to any files added to it. So in order to use subversion you need a repositoy.
First of all you will need the TortoiseSVN client, just grab it and install.
After installing it, it will add some new options to you Windows Explorer context menu, so right click in any folder and you will see 2 options, SVN Checkout and a TortoiseSVN sub menu.
First of all, you will need to create a folder to be your repository, this folder will store a copy of your projects stored in the subversion repository and keep track of their modifications, so create a folder called MyRepository in any place you like.
After creating the folder, right click on it, go to the TortoiseSVN menu and click on Create Repository Here.
That's all you need to create a local repository.
No you will need some code to add to it, so create a folder or just create a folder called temp and a HelloWorld.txt, open the HelloWorld.txt file and type something on it.
Now, right click on the temp folder and on the TortoiseSVN menu, select import.
You will need to select where you repository is, to do so, click on the "..." button on the top right corner, and select the MyRepository folder.
Type Initial Import on the Import Message and click OK.
I'll explain what you just did, because it can be tricky to understand.
When you created your Repository, you just created an empty database, and the import you just did, added your project to that database, so now you can access your project using the database and send your changes to the database.
Create a new folder anywhere and call it MyWorkingCode, now, right click on this folder and select SVN Checkout, this window should pop up:
As you did in the import process, click on the top right button and select the MyRepository folder, don't change the checkout directory, now just click the OK and you will notice that Subversion starts adding your files to your MyWorkingCode folder.
Notice that now your MyWorkingCode folder has a green icon on it, it means that the source code in that folder wasn't modified and it is exactly how it was on the subversion repository when you checked it out.
Inside this folder you should find your HelloWorld.txt, change something in this file and save it, after saving you will notice that both the file and the folder containing it will have a red icon on them, that means that they were modified.
Now you have two options, send those modifications to the database, or revert the stated of the file back to the state it was when you checked it out, it is a very powerfull thing, because now you can just mess everything up and with just a click you have everything back to normal in seconds!
Try it out, delete the HelloWorld.txt file and after that right click on your MyWorkingCode folder and select Revert on the TortoiseSVN sub menu, click OK on the window that will pop up and feel the power, your file that was deleted was restored!
Now, Edit your HelloWorld.txt again and save it. After that, right click on you MyWorkingCode folder and select SVN Commit, you will notice that a Window will pop up and in the bottom panel, you will see your modified File, double click on it, you should see this window:
It shows the differences between your working file and the state the file was when you checked it out, just close this window and click on the OK button in the Commit window, it will send your modifications to the database and show the new revision number, this means that now you have 2 versions of this file on the repository, and you can get them at any time, just checking out the specific revision, and also you can revert the file to any past revision you like.
For now it's just it, I don't want to scare you as I was scared by the SVN Book, so I'll try to post a better explanation of commit and other subversion features in a near future, stay tunned.