Support / KnowledgeBase

 
Search the KnowledgeBase Search

Using Subversion

  • Applies to: (gs)

  • Difficulty: Easy

  • Time needed: 5 minutes

  • Tools needed: None

 

Subversion (SVN) is a version control system initiated in 2000 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation.

Subversion is well-known in the open source community and is used on many open source projects, including Apache Software Foundation, Django, Ruby, Mono, SourceForge.net and Tigris.org. Google Code also provides Subversion hosting for their open source projects.

Subversion is released under the Apache License, making it free software.

This article has the following dependencies:

  • mt-example.com is used as an example. Please be sure to replace this text with the proper information for your site or server.
  • This article assumes that you have a basic understanding of svn usage.  Please consult the authoritative site for subversion here for futher assistance.
  • Creating Your Repository:

    1. SSH access must be enabled for the user that will be using the repository. Please see our article (gs) Enabling SSH Access.


      NOTE:

      If you want a user other than serveradmin to use your repository please enable ssh access for that user first.  Then create the repository using that account.

    2. Log into your (gs) Grid-Service using SSH.  If you are setting up this repository as serveradmin then switch to your data directory and create a svn directory:


      cd data
      mkdir svn && cd svn
      

      If you are creating this repository as another user you should remain in that user's home directory.  The rest of this article assumes that the serveradmin user is being used.  Please change any paths accordingly otherwise.

    3. Inside your svn directory use the svnadmin command to create your repository:


      NOTE:

      •  You MUST use the filesystem type fsfs to ensure svn database compatibility.
      • Be sure to substitute <repo_name> with the name you would like to give your repository.
      svnadmin create --fs-type fsfs <repo_name>
    4. Now you should create a layout for your various projects. The preferred method is the trunk/branch/tags style.  Change to a directory you have created for your project and run the following commands.  For this example we have created another directory in data called sites:


      NOTE:

      The below example will create two projects named website1 and website2.  Please change accordingly.

      mkdir /home/#####/data/sites
      cd /home/#####/data/sites/
      mkdir website1
      mkdir website1/trunk
      mkdir website1/branches
      mkdir website1/tags
      mkdir website2
      mkdir website2/trunk
      mkdir website2/branches
      mkdir website2/tags

    5. Use the svn command to import the layouts you just created:

      NOTE:

      Remember to replace ##### with your (gs) site number.

      svn import /home/#####/data/sites file:///home/#####/data/svn/<repo-name> --message "Creating initial repo."

    6. Your repository is now configured.  You can always view its details using the following command:

      svn list --verbose file:///home/#####/data/svn/<repo-name>

    Connect to your Repository:

     

    NOTE:

    The (gs) Grid-Service does not currently support http style links for subversion repositories. Instead svn must be used through SSH.

    • The following example, run on your local computer, would list the contents of your repository on the Grid:

      
      svn ls svn+ssh://mt-example.com@mt-example.com/home/#####/data/svn/<repo-name>
    • The following example, run on your local computer, would checkout your website1 trunk to a local directory named website 1:

      NOTE:

      It is normal to have to enter your password twice when performing a checkout.  This command opens two repository connections.


      
      svn co svn+ssh://mt-example.com@mt-example.com/home/#####/data/svn/<repo-name>/website1/trunk website1
      

    Further Reading:


    Revisions:

    07-07-2009: Changed ssh connection strings.
    06-30-2008
    : Added 3rd party info on connecting with TortoiseSVN. Thanks to Dejan Vesić!
    06-06-2008: corrected usage example in final code box.  Thanks to Collin Allen for feedback!!
    01-02-2008: clarifications and corrections.


    User Comments

    No visitor comments posted. Post a comment

    Fields marked with an asterisk(*) are required. Comment on this article

    Fill out the form below if you would like to comment on this article.
     
     
     

    (code is not case-sensitive)
     
    Submit
     
     

    Continue