Using Subversion
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.
Creating Your Repository:
-
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.
-
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 svnIf 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.
-
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> -
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 - 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." - 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:
- To set up a repo for multiple users follow this KB:
HOWTO: (gs) SVN multiple users
- Additional info for using Eclipse (This site is not owned by (mt) Media Temple and therefore unsupported):
http://www.breakitdownblog.com/2007/[...]subversion-svnssh-with-eclipse
- Additional 3rd party info on how to connect to SVN via windows can be found at:
http://www.cs.ubc.ca/~vailen/svn_howto.htm - Additional 3rd party info on how to connect to SVN via TortoiseSVN can be found at (This site is not owned by (mt) Media Temple and therefore unsupported): :
http://www.vesic.org/english/blog/software/how-to-use-tortoisesvn-to-access-mediatemple-subversion-over-svn-ssh/
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.
Fields marked with an asterisk(*) are required. Comment on this article