Subversion access with svn+ssh
<-- Back to Documentation

The most basic method for accessing Subversion repositories under your csoft.net account is the svn+ssh protocol, which uses the SSH protocol to secure communication between your Subversion client and the server. When connecting via svn+ssh, the client-side URL looks like:

  svn+ssh://user@ssh.yourdomain.com/path
  svn+ssh://user@server.csoft.net/path

The svn+ssh method requires the use of real Unix accounts and Unix file permissions (unlike the svnserve and DAV methods, which use different authentication mechanisms). You can connect using your main csoft.net account, or use different accounts. Accounts created via "Subversion Service / SVN Accounts" in the web interface (or "svn add" in the shell interface) are restricted to Subversion access. It is also possible to connect using a general-purpose web/ftp/shell account (created via "Unix Accounts" in the web, or "subacct add" in the command-line).

For SVN-only accounts, you may want to use SSH public keys for convenient passwordless authentication. You can manage SSH public keys for SVN accounts by clicking on the account in the "SVN Accounts" list from the web interface (or using the "svn pubkey" commands in the CLI).

Since the svn+ssh method relies regular Unix permissions, you will need to make sure that the SVN users have access to the repository files. If you have a group of users working on a same project, it is a good idea to create a corresponding Unix group for them (see "Unix Groups" in the web interface, or use the "group" commands in the CLI). Then, from the "Files" section of the web interface, you can change the group ownership of the repository to the new group (click "Edit" under the "Group" header; the change will be applied recursively). Alternatively, you may also use chmod and chgrp directly from your shell.

Installing client software

We assume that you want to access SVN repositories on the server from a remote client, such as your workstation. If your workstation is Unix-based, you can download the original Subversion client in binary package or source code form. For Windows users, we recommend TortoiseSVN, a windows shell explorer extension freely available.

Initializing the repository

On the server, use the svnadmin tool to create a new repository:

  $ svnadmin create $HOME/my-repo

This command would create a new repository structure under ~/my-repo.

Generating a working copy

On your workstation, use the svn import command to create a working copy of the repository:

  $ mkdir my-files
  $ svn import -m "My files" my-files \
        svn+ssh://my-username@my-server/my-home/my-repo
  $ rm -rf my-files
  $ svn checkout svn+ssh://my-username@my-server/my-home/my-repo/my-files

TortoiseSVN users can generate a working copy by right-clicking on an empty directory, selecting the SVN Checkout... command and entering the URL of the repository in the dialog.

Importing unversioned files

The svn import command is useful for recursively adding the contents of a directory to a repository:

  $ export SVNROOT="svn+ssh://my-username@my-server/my-home/my-repo"
  $ svn import -m "My website" www $SVNROOT
  $ mv www www.orig
  $ svn checkout $SVNROOT/my-website www
Importing files from CVS

If you have an existing CVS repository that you want to convert to subversion, the cvs2svn tool can be used. It is available on your server, but you can also run it on your local computer. Please note that cvs2svn is very resource-intensive and is designed for one-time only conversions, not repeated synchronizations.

Creating a read-only mirror of a remote repository

It is possible to create a read-only mirror for a remote repository thanks to the svnsync command (simply copying the subversion database files over is not a safe way to do this). See the svnsync guide for more information.

Relocating an existing Subversion repository

To move an existing repository from a different server, it is best to use the svnsync method in order to preserve all attributes. Existing working copies do not need to be regenerated after the repository has been moved to the new server. Instead, the following command can be used:

  $ svn switch --relocate old-url new-url
Miscellaneous examples
  $ cd my-website
  # See the local modifications to text files since the last commit.
  $ svn diff |more
  $ svn diff |vim -
  # Merge changes committed to the repository since last update/checkout.
  $ svn up
  # Add an existing directory and all the files it contains.
  $ svn add old-images/
  
  # Create an empty directory.
  $ svn mkdir new-images/
  
  # Remove a file or directory.
  $ svn remove foo.txt
  
  # Rename a file or directory on the repository.
  $ svn move file1 file2
  $ svn move dir1/ dir2/
  # Display the history information for a file or directory.
  $ svn log images
  #
  # Commit changes to the working copy into the repository. Unless the
  # commit message is given on the command line with "-m", it will bring
  # up your text editor ($EDITOR).
  #
  $ svn commit
  $ svn commit -m 'Summary of changes'

Links


This web site - © 2014 Csoft.net Hosting, Inc.
(Contact Us) (Privacy Policy)
  Valid HTML 4.01 Transitional