I’m going to make a few assumptions before I start this tutorial.
- You have windows (2000+)
- You have TortoiseSVN client
- You are familiar with the basics of SVN, i.e. you have checked out a trunk onto your local machine.
- You SVN repository is available over HTTP, e.g. http://svn.yourdomain.com/svn
For the setup I am going to be working with example directories, in this case “C:/dev” is your development directory on your local machine. You can of course make this whatever you choose but all other paths in this tutorial will need to reflect that change you have made. So i’m now going to checkout a project into my development environment at “C:/dev/example-svn”. If the person responsible for setting up your SVN repository has done their job properly you should see 3 directories, “trunk” (containing the latest code changes), “tags”, and “branches”. Your setup may differ from this, but i’ll assume you can translate that to whatever you environment is.
Now a little word about what “Tags” and “Branching” are:
By the method with which SVN operates, essentially both tags and branches are the same thing, i.e. a snapshot of the trunk that you are working with. Thus when you create a tag/branch you are creating a copy of a particular revision of your trunk code (it could be a branch of a branch etc, but lets not go down that road just yet). Doing this allows you to have 2 or more simultaneous code copies that can be altered separately, but merged back together at any time (covered in Part 2).
It’s worth noting that SVN doesn’t actually create a copy of the code base, it merely creates files that represent the differences between the trunk and the tag that was created. Nothing for you to worry about really, but basically stops your hard drive space from being used up with lots of different copies.
How to do it:
- Using your TortoiseSVN client navigate to your trunk directory (e.g. C:/dev/example-svn/trunk)
- Right click inside the directory (do NOT select a folder inside this directory, just some blank space).
- Select TortoiseSVN > Branch/tag
- Change the “To URL” to “http://svn.yourdomain.com/svn/tags/stable/0.1″
- Select either the “HEAD” or pick a revision number (you can browse revisions)
- Add a comment
- Hit “Ok”
Note in the above, for the tagged URL I chose a structure inside tags to represent a “stable” release, and a meaningful version number “0.1″.
Now, once you’ve done this you will need to head into “C:/dev/example-svn/tags”, Right-Click, and choose “SVN Update”. This should pull out the tagged release code we just have created.
Now if you perform any changes inside the tag or the trunk and commit them you will see they are only contained within their respective directories.
Why would you do this:
- You want to have a “production”, or series of “stable” releases.
- The tagged versions can be modified with fixes (for production release) and not be affected by any changes in the trunk
- You wish to perform fixes against a production code state, and test them against the last production release, and then re-merge them into the trunk (merging will be covered shortly in part 2).