Using Subversion: A Quick Tour

This section provides a very quick tour of using Subversion for version control. We start with the initial version of a project for importing into Subversion:

$ find /tmp/hello -print    Show directory layout
/tmp/hello
/tmp/hello/branches         Directory for branch development
/tmp/hello/tags             Directory for tagged releases
/tmp/hello/trunk
/tmp/hello/trunk/hello.c    Mainline development is done on the trunk
/tmp/hello/trunk/Makefile
/tmp/hello/trunk/README

The next steps are to create the repository and then to import the project into it:

$ svnadmin create /path/to/svnrepos
$ svn import /tmp/hello file:///path/to/svnrepos -m "initial import"
Adding         /tmp/hello/trunk
Adding         /tmp/hello/trunk/hello.c
Adding         /tmp/hello/trunk/Makefile
Adding         /tmp/hello/trunk/README
Adding         /tmp/hello/branches
Adding         /tmp/hello/tags

Committed revision 1.

Now that the project exists in Subversion, we check out a working copy into a sandbox underneath our home directory and start making changes:

$ cd                                           Move to home directory
$ svn checkout file:///path/to/svnrepos hello  Check out working copy
A  hello/trunk
A  hello/trunk/hello.c
A  hello/trunk/README
A  hello/trunk/Makefile
A  hello/branches
A  hello/tags
Checked out revision 1.

$ cd hello/trunk                               Change to sandbox
$ vi message.c hello.c Makefile                Make changes
3 files to edit

$ cat message.c                                Show newly created file
const char message[  ] = "hello, world!";
$ make                                         Compile program and test it cc -c -o hello.o hello.c cc -c -o message.o message.c cc -O hello.o ...

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.