Apache Subversion Basics with TortoiseSVN 🌱

Install TortoiseSVN

  1. Download TortoiseSVN Download
  2. Install TortoiseSVN

Creating a New Repository

  1. Navigate to where you are storing your Subversion repository databases
  2. Create a new folder matching the application name
  3. Inside the new folder, right click in the whitespace > TortoiseSVN > Create respository here
  4. When the dialog appears, click the Create folder structure option, this will create the standard "trunk", "branches" and "tags" directories inside the new repository

Creating a Working Directory

  1. Create a folder to contain the working copy of the code, this could be on a development web server
  2. Inside the new application folder, right click in the whitespace > SVN Checkout...
  3. Input the URL to the repository to work with, this can be either a file:// or http(s):// URL if Apache HTTPD has been setup for Subversion (Video link: )
    Examples:
    file:///E:/SVN_Repos/new_code/trunk
    https://svn.i12bretro.local/new_code/trunk

Committing Changes to the Repository

  1. After completing code changes, right click in the white space of the working directory > SVN Commit...
  2. Input meaningful comments about the changes completed
  3. Click OK

Importing Existing Code Into Subversion

  1. Create the Subversion repository using the steps above
  2. Navigate to the folder that contains your code
  3. Right click in the whitespace > TortoiseSVN > Import...
  4. Input the URL to the repository to work with, this can be either a file:// or http(s):// URL if Apache HTTPD has been setup for Subversion (Video link: )
    Examples:
    file:///E:/SVN_Repos/import_code/trunk
    http://svn.i12bretro.local/import_code/trunk
  5. Input a meaningful comment about the state of the code being imported
  6. To convert the current directory into a working directory after successfully importing the code into the repository, simply right click in the whitespace > SVN Checkout...
  7. Input the URL to the repository to work with
  8. Verify the checkout path, making sure no unwanted sub-directories were added based on the repository URL (for example, I've found that TortoiseSVN will add /trunk to the checkout directory)
  9. Click OK
  10. A dialog will display stating that the directory selected is not empty > Confirm the target folder path and Click Checkout

Deploying Updates with Subversion Workflow

  1. After completing development and testing the code, you'll be ready to deploy it to a production environment
  2. Navigate to the folder on the production environment > Right click in the whitespace > SVN Checkout...
  3. Input the URL to the repository to work with, this can be either a file:// or http(s):// URL if Apache HTTPD has been setup for Subversion
    Examples:
    file:///E:/SVN_Repos/import_code/trunk
    https://svn.i12bretro.local/import_code/trunk
  4. After the checkout completes the production directory will contain an exact copy of code in /trunk of the repository

Relocating Subversion Repository

This is useful if the location (file path or URL) of the repository has changed but the repository remains the same. For example, migrating to a new server or from file paths to Apache HTTPD based URLs

  1. Navigate to the working directory in Windows Explorer
  2. Right click in the white space > TortoiseSVN > Relocate...
  3. Input the URL to the new location of the matching repository
    Examples:
    file:///E:/SVN_Repos/import_code/trunk
    https://svn.i12bretro.local/import_code/trunk
  4. A dialog stating the relocate succeeded should be displayed
  5. Right click in the white space > TortoiseSVN > Repo-browser
  6. The new updated URL should be displayed

Tagging Releases

Once development and testing are completed for a version of the code, you can create a tag in Subversion. This is a snapshot of the code set and can we used to roll back to the exact version in the future if needed

  1. Right click in the whitespace anywhere in Windows
  2. Select TortoiseSVN > Repo-browser
  3. Input the URL to the repository to work with
  4. Right click on the trunk folder in the left navigation pane > Copy to...
  5. Input the URL to the new tag to create, for example http://svn.i12bretro.local/code_repo/tags/1.0
  6. Click OK
  7. Input a comment such as "Creating v1.0 tag" > Click OK
  8. In the Repo browser, expand the tags directory to see the newly created tag
  9. To revert back to this version of the code, just use the tag URL when checking out into a working directory, for example http://svn.i12bretro.local/code_repo/tags/1.0

Include a directory in the repository, but ignore its contents

This scenario is useful for a directory that is required by the application but where the contents is unique to the deployment. For example, an upload, temp, log or attachment directory.

  1. Right click on the directory > TortoiseSVN > Properties
  2. Click the New... button > Other
  3. Select svn:ignore from the Property name dropdown
  4. Type * in the Property value field
  5. Click OK
  6. Right click in the white space > SVN Commit...
  7. Type a meaningful comment denoting the change
  8. Click OK