Time to Operate on Your Repository
Now that the repository has been set up, you can operate on it. You will usually be in one of two situations after creating a Subversion repository:
- You have some code you want to put in the repository immediately.
- You are just beginning a project and have no code yet.
If you're in the first scenario, you can either import your code into the Subversion repository using the import command, or you can copy the existing code into your working copy (discussed in the next paragraph) and then add it to the repository with the "svn add" command (discussed in the upcoming "Subversion in the Development Process" section). This tutorial does not cover the import command, but you can find out more about it in the Subversion manual.
For now, assume you are starting from scratch. Now that you have created the repository, you need to check it out and create a working copy in which you can create and change files. The working copy is where you work on your files in isolation from other developers. Use the following command to check out your working copy:
svn checkout file:///srv/svn/first-project-repository first-project
This command checks out the first-project-repository and places it in a directory called first-project in the current directory. If you did not want the first-project directory in the current directory, you can simply move it to another location.
Note that there are three slashes after "file:". The first two slashes are part of the URL protocol identifier. The analogous situation with Web access is how Web site URLs always have "http://" in front of them (note the two slashes after the http). The third slash after "file://" is part of the pathin other words, the path is "/srv/svn/first-project-repository". Subversion supports several protocols in the standard distribution (see Table 1).
||Direct access (local filesystem repository)
||Transport via WebDAV protocol on Apache server
||Transport via WebDAV using SSL to encrypt data
||Transport via custom protocol with svnserve server
||Transport via custom protocol with svnserve server, tunneled through ssh connection
|Table 1. Protocols Supported in Standard Subversion Distribution|
To access a Subversion repository on another machine, you must use one of the network protocols (http, https, svn, or svn+ssh). The easiest protocol to set up probably is svn+ssh, if you already have ssh access to the remote machine. In that case, you do not have to do anything further to set up remote access to the repository (apart from creating the repository with the svnadmin create command on the remote machine, of course).
Now that you have checked out a working copy of first-project, change into the first-project directory that you created by issuing the "svn checkout file:///srv/svn/first-project-repository first-project" command before. Issue the following commands:
svn mkdir branches
svn mkdir tags
svn mkdir trunk
The last command (the commit operation) will ask you to enter a log message. Just enter "started project", and then exit the editor. Subversion should check in your changes.
You might be wondering why you just created three directories. The accepted way of handling branches and tags in Subversion is through file and directory operations. CVS has a tag command (more accurately, the "cvs tag" command) that provides branch and tag functionality. In Subversion, the branch and tag functionality are implicit because you can create copies of files and directories and tell Subversion to remember that the copies are related to one another. In other words, you can create branches and tags by simply telling Subversion to copy the trunk directory to a new directory underneath either the branches directory or the tags directory. An upcoming section elaborates on branches and tags.