Setup SVN Local Repository

0. FAQ First

Q: I heard that Subversion is an Apache extension? Does this mean I have to set up Apache to use Subversion?

A: The short answer: no. The long answer: if you just want to access a repository, then you only need to build a Subversion client. If you want to host a networked repository, then you need to set up either Apache2 or an “svnserve” server.

for more faq: http://subversion.tigris.org/faq.html

1. Creating The Repository With TortoiseSVN 

  1. Open the windows explorer
  2. Create a new folder and name it e.g. SVNRepository
  3. Right-click on the newly created folder and select TortoiseSVN → Create Repository here….

A repository is then created inside the new folder. Don’t edit those files yourself!!!. If you get any errors make sure that the folder is empty and not write protected.

2. Local Access to the Repository

To access your local repository you need the path to that folder. Just remember that Subversion expects all repository paths in the form file:///C:/SVNRepository/. Note the use of forward slashes throughout.

To access a repository located on a network share you can either use drive mapping, or you can use the UNC path. For UNC paths, the form is file://ServerName/path/to/repos/. Note that there are only 2 leading slashes here.

3. Repository Layout

Before you import your data into the repository you should first think about how you want to organize your data. If you use one of the recommended layouts you will later have it much easier.

There are some standard, recommended ways to organize a repository. Most people create a trunk directory to hold the “main line” of development, a branches directory to contain branch copies, and a tags directory to contain tag copies. If a repository holds only one project, then often people create these top-level directories:

/trunk
/branches
/tags

If a repository contains multiple projects, people often index their layout by branch:

/trunk/paint
/trunk/calc
/branches/paint
/branches/calc
/tags/paint
/tags/calc

…or by project:

/paint/trunk
/paint/branches
/paint/tags
/calc/trunk
/calc/branches
/calc/tags

Indexing by project makes sense if the projects are not closely related and each one is checked out individually. For related projects where you may want to check out all projects in one go, or where the projects are all tied together in a single distribution package, it is often better to index by branch. This way you have only one trunk to checkout, and the relationships between the sub-projects is more easily visible.

So if you haven’t already created a basic folder structure inside your repository you should do that now:

  1. create a new empty folder on your hard drive (NOT INSIDE THE Already created repository – SVNRepository)
  2. create your desired top-level folder structure inside that folder – don’t put any files in it yet!
  3. import this structure into the repository via a right click on the folder and selecting TortoiseSVN → Import… This will import your temp folder into the repository root to create the basic repository layout.

Note that the name of the folder you are importing does not appear in the repository, only its contents. For example, create the following folder structure:

C:TempNewtrunk
C:TempNewbranches
C:TempNewtags

Import Layout C:TempNew into the repository root, which will then look like this:

/trunk/branches/tags

You can also use the repository browser to create new folders directly in the repository.

4. Import Content

Before you import your project into a repository you should:

  1. Remove all files which are not needed to build the project (temporary files, files which are generated by a compiler e.g. *.obj, compiled binaries, …)
  2. Organize the files in folders and subfolders. Although it is possible to rename/move files later it is highly recommended to get your project’s structure straight before importing!

Now select the top-level folder of your project directory structure in the windows explorer and right click to open the context menu. Select the command TortoiseSVN → Import which brings up a dialog box for you to enter the URL of the repository into which you want to import your project.

As soon as you press OK TortoiseSVN imports the complete directory tree including all files into the repository. As before, the name of the folder you import does not appear in the repository, only the folder contents. The project is now stored in the repository under version control. Please note that the folder you imported is NOT under version control! To get a version-controlled working copy you need to do a Checkout of the version you just imported.

Though this perfectly suits to windows user, for Linux always adviced to go with command line which is the best way for now. Though a couple of existing desktop clients for accessing SVN repos, all of them have it’s own shortcomings. Also, none of them are not even near to Windows’ TortoiseSVN client in terms usage, features, options and maintenance.

Will post seperate post for SVN setup for linux users with all the commonly required command lines.

Leave a Reply

Your email address will not be published. Required fields are marked *