Subversion Repositories

From CS Support Wiki
Revision as of 20:38, 8 April 2010 by Ejs3s (Talk | contribs) (Checkout Files)

Jump to: navigation, search

Quick SVN Introduction

Create a Repository

Svnadmin is the tool subversion uses for administrative tasks, such as making repositories and backups. To create a repository, first you need to change directory to where you want to create the repository. Then use the create command.

cd /home/reh4j
svnadmin create svnroot

This creates a repository called svnroot. It will appear as a folder, but you will not need to deal directly with this folder. Instead, you will use subversion commands to interact with your repository.

Import Files

Once the repository has been created, the svn tool can be used to manage it. Before you can import a project, you need to create a folder for it - the command for this is svn mkdir.

svn mkdir file:///home/reh4j/svnroot/project1

Subversion will open up a text editor and request a log message. Cd into the directory that you want to import, and then use svn import.

cd /home/reh4j/.../project1
svn import file:///home/reh4j/svnroot/project1

Checkout Files

Even though the repository now stores a copy of your files, you won't interact directly with those files. Instead, you will check out a working copy, which you can then modify. Change directory to wherever you want the working copy to exist, and then run svn checkout.

cd /home/reh4j/svn_work
svn checkout file:///home/reh4j/svnroot/

A new folder, project1, will now exist in the svn_work directory. This is the working copy of your subversion repository.

Modify and Commit Files

After you have modified and want to commit files to the repository, run svn commit in the checked out project1 folder.

cd /home/reh4j/.../project1
svn commit

Subversion will pop up a text editor, prompting you to enter a log message. Emacs is the default editor, but you can change this by changing the SVN_EDITOR environment variable. Or you can bypass the editor entirely by including the log message in the command line with the commit.

svn commit -m "enter log message here"

Subversion Repository URLs

Subversion repositories can be accessed through many different methods - on local disk, or through various network protocols. A repository location, however, is always a URL.

Schema Access Method
file:/// direct repository access (local disk)
http:// access via WebDAV protocol to Subversion aware Apache server
https:// same as http:// but with SSL encryption
svn:// access via custom protocol to an svnserve server
svn+ssh:// same as svn://, but through an ssh tunnel

Using svn+ssh, the URL for an SVN repository is: svn+ssh://

Example: Assume user alice wants to connect to server Power1 in order to access her SVN repository, which is located in her home directory in the folder svn_root.

The URL she would use is: svn+ssh://