Page 150 -
P. 150
On a Windows system, svnadmin uses a Windows-style path to create the repository. The
following commands will create a repository in the c:\svn\repos\ directory. Note that this is
a raw path, and not a file:/// URL:
C:\>mkdir c:\svn
C:\>svnadmin create c:\svn\repos
A shared folder on a network is all it takes to set up a repository that multiple program-
mers can use. A single programmer can do the same on her own machine to store her own
work in a local repository.
Once the empty repository is created, an initial set of files can be added to it using the svn
import command, which allows files to be added to a repository without checking it out:
svn import [PATH] URL
There are several ways that the directories in a repository can be structured. One easy way
to do it is to have a root-level folder for each project. Each project folder contains three
subfolders: trunk, tags, and branches. The working version of the source code is stored in
the trunk folder. (The other two folders are reserved for more advanced version control
activities, which are beyond the scope of this book.)
For example, to import a project called hello-world that contains two files, hello-world.c and
hello-world.h, they should be put into a folder:
$ mkdir tempimport
$ mkdir tempimport/hello-world
$ mkdir tempimport/hello-world/trunk
$ mkdir tempimport/hello-world/tags
$ mkdir tempimport/hello-world/branches
[copy hello-world.c and hello-world.h into the import/hello-world/trunk directory]
$ svn import tempimport/ file:///usr/local/svn/repos/ -m "Initial import"
Adding tempimport/hello-world
Adding tempimport/hello-world/trunk
Adding tempimport/hello-world/trunk/hello-world.c
Adding tempimport/hello-world/trunk/hello-world.h
Adding tempimport/hello-world/branches
Adding tempimport/hello-world/tags
Committed revision 1.
Note that a log message reading “Initial import” was passed to svn using the -m flag. If this
is omitted, Subversion will launch the default editor to edit the log message. The environ-
ment variable SVN_EDITOR can be used to change the default editor. (Many Windows users
prefer to set this variable to notepad.)
The Subversion repository is now ready for use. Additional files can be added either by
using the svnadmin import command or by checking out a branch of the repository and
using the svn add command.
142 CHAPTER SEVEN