TortoiseSVN for the single user

Introduction

Just like TortoiseCVS, TortoiseSVN is a Windows application can be used either as the client side of the open-source SVN source control manager (SCM), or be used as a stand-alone application for a single-user. Subversion is an improved CVS, as it lets you rename/move files and directories, and supports atomic commits. RapidSVN is another SVN client for Windows, based on wxWidgets.

The Big Picture

Setup

  1. Download and install the latest and greatest
  2. Create a directory to hold the repository, eg. C:\REPO
  3. To avoid dumping all files at the root of the repository, create a directory structure: In Windows Explorer, right-click on any file or folder > TortoiseSVN > Repo-browser. As URL, indicate where you created the repository, eg. file:///C:/REPO . In the Repository Browser, right-click and choose "Create folder...". Give it a name for the first project that you'll add to SVN, eg. "My First Project".

    An alternative is to create a directory structure in a temporary directory, right-click on it, and choose Import: TortoiseSVN will create this structure in its repository

    Note: To access a local repository with no SVN server running, you can use either "file://localhost/path/to/repo" or "file:///path/to/repo" (note the three forward slashes, due to lack of hostname; file:///C:/SVNRepository/).
     
  4. To import your first project into SVN, go to the directory from which TortoiseSVN will import files, remove files that you don't need to put under source control (eg. *.OBJ, *.EXE, etc.)
  5. Right-click on this directory > TortoiseSVN > "Import...". As "URL of Repository", aim at the folder "My First Project", and click OK. All the files and sub-directories have been added to the repository. You can now delete everything in this work directory that was used temporarily to import files into Tortoise
  6. Next, to actually work on this project that is now under source control, we need to check it out from the repository: Go to an empty location that will be used as your work directory, right-click on it, and select "SVN Checkout...". Select the project, and hit OK: All the files and sub-directories are checked out into the local work directory, ready to be used with your favorite development tools. Note that, by default, SVN doesn't put locks on files, so, in case you checked out the wrong project, you are free to delete files and start again.
  7. Once you're done, right-click on your work directory, and choose"SVN Commit...". If you use TortoiseSVN in client-server mode, choose TortoiseSVN > Update before committing changes, to make sure no changes were made by someone else on the server while you were editing them on your side.

Basic operations

Creating a repository

Launch Windows Explorer, create a new directory, right-click on it, choose the TortoiseSVN menu, and choose "Create repository here".

"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) or by project (/paint/trunk).

For unrelated projects you may prefer to use separate repositories. When you commit changes, it is the revision number of the whole repository which changes, not the revision number of the project.

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
  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."

Commiting original files

"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 the Import dialog box."

Exclude/Ignore pattern

"Exclude patterns are used to prevent unversioned files from showing up e.g. in the commit dialog. Files matching the patterns are also ignored by an import. Exclude files or directories by typing in the names or extensions. Patterns are separated by spaces e.g. */bin */obj *.bak *.~?? *.jar *.[Tt]mp. The first two entries refer to directories, the other four to files. These patterns use filename globbing. Read Section 5.11.1, “Filename Globbing in Ignore Lists” for more information."

Check out

"Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different subdirectories to come from different locations in a repository, or perhaps from different repositories altogether. If you want every user to have the same layout, you can define the svn:externals properties."

Update

"Sending the changes you made to your working copy is known as committing the changes. But before you commit you have to make sure that your working copy is up to date. You can either use TortoiseSVN > Update directly. Or you can use TortoiseSVN > Check for Modifications first, to see which files have changed locally or on the server."

Commiting changes

"If your working copy is up to date and there are no conflicts, you are ready to commit your changes. Select any file and/or folders you want to commit, then TortoiseSVN > Commit...."

Running a program to respond to an event

Hook scripts

Managing files

"Other commands are available as drag handlers, when you right drag files or folders to a new location inside working copies or when you right drag a non-versioned file or folder into a directory which is under version control."

Exporting

"Sometimes you may want a copy without any of those .svn directories, e.g. to create a zipped tarball of your source. Instead of making a copy and then delete all those .svn directories manually, TortoiseSVN offers the command TortoiseSVN > Export...."

Backing up a repository

svnadmin hotcopy path/to/repository path/to/backup --clean-logs

(Reading notes) TortoiseSVN - A Subversion client for Windows Version 1.4.1

From TortoiseSVN - A Subversion client for Windows Version 1.4.1

"A typical Subversion repository often holds the files (or source code) for several projects; usually, each project is a subdirectory in the repository's filesystem tree. In this arrangement, a user's working copy will usually correspond to a particular subtree of the repository.

Each time the repository accepts a commit, this creates a new state of the filesystem tree, called a revision. Each revision is assigned a unique natural number, one greater than the number of the previous revision. The initial revision of a freshly created repository is numbered zero, and consists of nothing but an empty root directory.

Unlike those of many other version control systems, Subversion's revision numbers apply to entire trees, not individual files. Each revision number selects an entire tree, a particular state of the repository after some committed change. It's important to note that working copies do not always correspond to any single revision in the repository; they may contain files from several different revisions.

svn commit commits a single file, while svn update uploads changes made to your entire working directory. It's not until you perform an update that the revision numbers of the files in your working directory will match those in the repository.

Each directory in your working copy contains an administrative subdirectory called .svn. For every file in a directory, Subversion keeps a copy of each file in the administrative area. This copy is an unmodified (no keyword expansion, no end-of-line translation, no nothing) copy of the file as it existed in the last revision (called the “BASE” revision) that you updated it to in your working copy.

To create a repository with Windows Explorer:

  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.

To access your local repository you need the path to that folder. If the repository lives on the local computer, use file:///C:/SVNRepository/. Note the use of forward slashes throughout.

If a repository contains multiple projects, you can create one directory per project (eg. /paint/trunk, /paint/branches, /calc/trunk, /calc/branches, etc.), but for totally unrelated projects, you may prefer to use separate repositories: When you commit changes, it is the revision number of the whole repository which changes, not the revision number of the project. Having 2 unrelated projects share a repository can mean large gaps in the revision numbers.

Next, let's create a structure in the repository:

  1. create a new empty folder on your hard drive
  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... Aim for the root of the repository. This will import your temp folder into the repository root to create the basic repository layout.

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

Next, import the files into the repository:

  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!
  3. 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... : enter the URL of the repository into which you want to import your project.

"

Q&A

How can I move the repository on a new drive?

If the disk structure is exactly the same, ie. same disk layout, same drive letter, same directory structure where the repository is living... you should be able to resume without TortoiseSVN noticing. Just make sure there's a /transaction sub-directory below repo/ .

I'd like to put an addition file under SCM, but it's not listed!

Make sure there's no more than one point in its filename, eg. my.file.txt. If that's the case, change the extra dot with something else, eg. my_file.txt.

With all projects under one repository, the version number increases each time a file is checked in!

This is by design, and it's an SVN feature. Any change made to a repository increases the overall version number, regardless of where a file lives in the repository. In other words, if you imported two projects, eg. file:///C:/Repository/Project1 and file:///C:/Repository/Project2, check-in's will increase the version number, no matter what project a file belongs to. It actually doesn't really matter, since public releases use their own version number, while repository version numbers are used for internal purposes only, eg. Widget 1.0 build 1234 would refer to repository version 1234 which was used for the public release 1.0.

Pro's and con's in the following threads:

No "Add" item when adding a new file to a project under source control

The file has to live in a work directory that is under source control. Right-clicking on a file that is located elsewhere will not display this item in the SVN pop-up menu.

Resources