SVN or Subversion is a source control repository technology that allows to save code statuses on a centralized server from which the developers can save the current status of their project, merge with what others devs have been doing, create branches of a project to develop new features or solve bugs in an isolated space and finally merge back to the trunk to include the changes into the next release.
SVN also has some clients that connect to the centralized repository and help you committing changes into it or getting the latest changes from it: one of them is Tortoise.
Getting a Repository
You can use Windows explorer to handle everything, so getting a project from the repository is as easy as creating a new folder anywhere in your computer, right click -> SVN Checkout… and the checkout browser opens like a Windows explorer window with a URL on the top to set the URL of the repository and then a sidebar with the folders to navigate. Notice that if you move around the files the URL changes, once you select the right folder you can click ok or copy the url and use it.
With Tortoise SVN you can get a repo more quickly if you already know the URL: right click on a Windows folder -> Tortoise SVN -> Repo browser, paste the URL of the repository you want to get and click Ok.
Committing
Very similar to the way we get a repo -> right click on a folder -> SVN Commit.
Important!: Contrary to Git, in which you usually commit changes before a pull, with SVN is preferable to Update (pull) before you commit (push). The reason is that you don’t have a local repository and if you try to commit and there’s a conflict that SVN can’t handle your commit will be aborted until you fix the conflicts.
Getting latest changes
Once you have already configured the link between your folder and the repo, to get the latest changes other devs have done just right click on the folder -> SVN Update.
Resolving merging conflicts
Sometimes two devs modify the same file and around the same area and SVN doesn’t know how to merge that. This is usually not a problem but when it does you get a tool for comparison that very easily allows you to select the parts you want to use, or if you want to use one and then the other (both) or if you prefer to manually write the combined result. This tool is quite useful and intuitive so I don’t see the need to explain how to use it.
Branching
To create a branch, you can get into the repository with right click -> Tortoise SVN -> Repo browser. Once there navigate to the branches folder and create a new folder to which you can now copy an existing trunk. As SVN doesn’t have local repos, you need to create a folder on the server to store and save a branch you are working on in order to make commits and have your checkpoints even if no one else is using that branch. On the client side just get that folder as a new repo.
Another way of doing this but using Tortoise SVN on the client side is: right click on folder -> Tortoise SVN-> Branch/Tag…
Once there you’ll have to set the URL on the repo where the branch is going to be saved, which usually will be under the branches/ folder, and a name for the branch. You have now three options to create the branch: head, specific version and working copy.
Working copy will use your local files to create the branch, which is useful if you were working on something you thought was going to be smaller but becomes too big or priorities change, then select this option and a branch will be created with these changes, not affecting the trunk/branch in which you were. Specific revision always helps when determining where a bug started happening or looking for a stable version, when thigns go incredibly wrong you’ll get yourself getting specific revisions to create branches. Head revision is probably the one you’ll use most of the time, it allows you to create the branch before you start working on it by getting the latest version of the project on the server.
Finally, there’s an option “switch working copy to new branch/tag” that allows you to automatically change the repo url to which your local copy is pointing so you work from the branch directly. If you don’t select this, you will have to create another folder later and get the repo from the recently created branch or else any changes you do on your local will still be pointing the trunk/branch you were on previously.
More about Tortoise SVN branches.
Merging branches
Once a branch needs to be merged into the trunk, just click on the folder -> Tortoise SVN -> Merge… and the wizard will help you with the rest.