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.
25 comentários:
Nice post, Fábio. This tutorial style will certainly help many people out there looking for good step-by-step information.
Since TSVN 1.5 came out there are some minor changes. Here is a nice link to quick videos showing how to use basic TSVN features. Hope it helps you as well.
http://pollvu.blip.tv/
hamy
Thanks hamy, that's a very good set of videos.
Thanks your post was most helpful and succeeded in allowing me to understand step by step how to get TSVN working.
Richard
Nice post. it really help me to setup repository in my office kvisionindia.com.
thnx a lot.
Has all projects must be place in one repository folder or each project must be in separate folder in repository?
for example:
myProj1 :
file:///E:/Projects Repository/trunk
myProj2 :
file:///E:/Projects Repository/trunk
or ??
thanks.
@mohammad
I recommend you to have just one repository for all your projects, something like this:
file:///E:/Projects Repository/MyProject1/trunk
file:///E:/Projects Repository/MyProject2/trunk
Thanks for this, it's really useful! Starting to get the hang of tortoise almost
Obrigado Fábio, ajudou bastante.
Faz um favor e manda essa sua página pra galera do Tortoise botar no Help deles.
Ver se eles aprendem a escrever documentação útil.
Thanks ;)
Thank you. This post was very helpful for me to begin a project.
thanks man, your post helped me figure out i first had to insert a file
Thank you.. It's very useful for a svn beginner like me..
I always have wanted to know how to use TortoiseSVN to create a local Subversion repository. Thanks.
Thanks! This is very very helpful!
Thank you...
This is really nice tutorial or beginner..
Hoping for more and more post from you...
Thanks a lot...
very nice and helpful post.
Direct, concise, informative , and clear. Thank u
nice, btw how i check out from other cpu? i'tried like this but it won't worked? file://192.168.0.1/D:/TES SVN/
thx, arced
Thanks a tons Mate.. It was great !!
thanks man..
Thanks!
it's really useful, will stay tuned!
Thanks Again.
Adrian
It is really a good idea! some of your best work by far. Thank you for the wonderful post.
Good Tutorial. I like the simple way of explaining things one at a time which also made me explore quite a few other options without knowing..but it will not matter as I am doing it on my own machine and on my own repository
Postar um comentário