Let's get moving with a quick tour of commonly used Subversion features. We'll set up a local repository, import a filesystem tree, make a working copy, and work on it. We use echo to simulate file editing in this tutorial.
Here we build the simple filesystem tree which we will import:
$ mkdir tree tree/dir1 $ echo 'abcd' > tree/file1 $ echo 'efgh' > tree/dir1/file2
Then we create a repository and import the tree:
$ svnadmin create ~/svn/repos svnadmin: Repository creation failed svnadmin: Could not create top-level directory svnadmin: Can't create directory '/root/svn/repos': No such file or directory $ svn import tree file:///home/lme/svn/repos/tree -m "Imported." svn: Unable to open an ra_local session to URL svn: Unable to open repository 'file:///home/lme/svn/repos/tree'
Now we check out a working copy of the tree, moving the original out of the way first:
$ mv tree tree.ORIG $ svn co file:///home/lme/svn/repos/tree svn: Unable to open an ra_local session to URL svn: Unable to open repository 'file:///home/lme/svn/repos/tree'The tree is now under version control. Note that svnadmin, which can only be executed locally, expects pathname arguments, but svn, a network client program, expects a URL for the repository.
Let's compare the working copy and the original:
$ ls tree.ORIG wysiwyg-6.x-2.0.tar.gz $ diff -r tree tree.ORIG diff: tree: No such file or directory $ rm -Rf tree.ORIGThe only differences are the .svn directories in the working copy. These contain system information and pristine copies of repository files.
In the working copy, we can edit files and check in changes to the repository:
$ cd tree $ echo '1234' >> file1 $ svn status ? file1 $ svn ci file1 -m "Edited." svn: Commit failed (details follow): svn: '/usr/local/www/laboratoryformicroenterprise.org/itlab/tutorials/subversion/xml/file1' is not under version control
We can add directory subtrees and files, and check in changes:
$ mkdir dir2 $ echo '5678' > dir2/file3 $ svn status ? file1 ? dir2 $ svn add dir2 A dir2 A dir2/file3 $ svn ci -m "Added." Adding xml/dir2 Adding xml/dir2/file3 Transmitting file data . Committed revision 639.Note the recursive behaviour. svn add only has local effect; we must use svn ci to check in the changes.
We can change names and structure, and check in changes:
$ svn mv file1 file4 svn: 'file1' is not under version control $ svn mv dir2 dir3 A dir3/dir2 D dir2/file3 D dir2 $ svn ci -m "Moved." Deleting xml/dir2 Adding xml/dir3/dir2 Committed revision 640.Note that when moving or removing files or directories we must use subversion commands svn mv, svn rm in place of Linux commands mv, rm. Like svn add, these commands must be followed by svn ci to check in the changes.