An Idiot's Guide To Installing A Version Control File Systems

An idiot's guide to implementing a version control system with an Anchor Systems shared user account, a step by step guide.

The aim of this tutorial is get the version system in place so you can see with confidence how easy it is to implement and get it working.

Substitute all UPPERCASE letters with your own account settings.


Log onto your Anchor user account and run the following commands.

SSH into your user account:

[user@yourmachine ~]$ ssh USER@ANCHOR_SERVER

Create a repository directory within your home account:

[useraccount@anchorserver ~]$ mkdir repo

Create a test directory within your home directory to be used for version control:

[useraccount@anchorserver ~]$ mkdir testing
[useraccount@anchorserver ~]$ cd testing

Create some files within the 'testing' directory using the touch command:

[useraccount@anchorserver testing]$ touch file1.txt
[useraccount@anchorserver testing]$ touch file2.txt

Create repository and import your files:

[useraccount@anchorserver ~]$ svnadmin create ~/repo/
[useraccount@anchorserver ~]$ svn import ~/testing/ file:///home/USER_ACCOUNT/repo/testing/trunk/ -m 'This is a test project'
Adding         /home/USER_ACCOUNT/testing/file2.txt
Adding         /home/USER_ACCOUNT/testing/file1.txt

Committed revision 1.

Server configurations are done! Your repository is in place and your 'testing' directory has been successfully imported and under version control.

Now onto your local machine...


On your local machine make sure the svn client is running.

Check svn version is installed on your machine:

user@yourmachine:~$ which svn

If the above didn't return a path (e.g. /usr/bin/svn), you will need to install the application. Please click here for instructions.

Once your client software is installed please proceed...

Now you can view your 'testing' directory within the repository on the Anchor server:

user@yourmachine:~$ svn list svn+ssh://ANCHOR_SERVER/home/USER_ACCOUNT/repo/

Create a directory to store your local working copy:

user@yourmachine:~$ mkdir workingcopy
user@yourmachine:~$ cd workingcopy

Download (check out) a local working copy of the files for you to work on:

user@yourmachine:~/workingcopy$ svn co svn+ssh://ANCHOR_SERVER/home/USER_ACCOUNT/repo/testing
A    testing/trunk
A    testing/trunk/file2.txt
A    testing/trunk/file1.txt
Checked out revision 1.

Change into the downloaded folder:

user@yourmachine:~/workingcopy$ cd ./testing/trunk/

Download Makefile and NOROLLOUT files to your local machine, save them into your working copy e.g(user@yourmachine:~/workingcopy/testing/trunk/).

Make configuration changes to the Makefile:

user@yourmachine:~/workingcopy/testing/trunk$ vi Makefile
RODIR := /home/USERNAME/testing

Add downloaded files to the repository:

user@yourmachine:~/workingcopy/testing/trunk$ svn add Makefile NOROLLOUT
user@yourmachine:~/workingcopy/testing/trunk$ svn ci -m 'Added Makefile  and NOROLLOUT files to repository'
Adding         trunk/Makefile
Adding         trunk/NOROLLOUT
Transmitting file data ..
Committed revision 2.

Everything is in place! Your version control system is ready to be used...

Example Usage

Edit 'file1.txt' using vi and write some content to it. To edit press 'i' for insert mode, and to save press 'Esc' for execute mode, then ':wq':

user@yourmachine:~/workingcopy/testing/trunk$ vi file1.txt
Writing some dummy test content to the file.

Preview changes within your working copy:

user@yourmachine:~/workingcopy/testing/trunk$ svn status
M file1.txt

Preview differences between new and old file:

user@yourmachine:~/workingcopy/testing/trunk$ svn diff file1.txt
Index: file1.txt
--- file1.txt   (revision 1)
+++ file1.txt   (working copy)
@@ -0,0 +1 @@
+Write some dummy test content to the file.

Commit your changes to the repository:

user@yourmachine:~/workingcopy/testing/trunk$ svn ci -m 'Added some dummy content'
Sending        trunk/file1.txt
Transmitting file data .
Committed revision 3.

Roll out changes, copy your working copy files to the original imported destination folder configured within the 'Makefile', please note you'll be prompted for your SSH password for your Anchor user account:

user@yourmachine:~/workingcopy/testing/trunk$ make out
svn up
At revision 3.
rsync \
                --verbose \
                --checksum \
                --recursive \
                --links \
                --times \
                --perms \
                --cvs-exclude \
                --compress \
                --rsh=ssh \
                --delete --delete-after \
                --exclude-from=NOROLLOUT \
                ./ trueweb@galleon:/home/trueweb/testing/
building file list ... done

sent 614 bytes  received 54 bytes  12.26 bytes/sec
total size is 43  speed up is 0.06

  Rollout time is DDD MMM DD YY:MM:II EST YYYY

Done! You've added a revision to the repository and successfully copied over your working copy into your imported directory.

Now let's say you have made a mistake, it's ok you can easily go back a revision.

View which current revision you are working on:

user@yourmachine:~/workingcopy/testing/trunk$ svn info
Path: .
URL: svn+ssh://ANCHOR_SERVER/home/USERNAME/repo/testing/trunk
Repository Root: svn+ssh://ANCHOR_SERVER/home/USERNAME/repo
Revision: 3

Before we update our working copy let's have a look at the differences from the previous revision '2' from the server repository:

user@yourmachine:~/workingcopy/testing/trunk$ svn diff -r 2 svn+ssh://ANCHOR_SERVER/home/USERNAME/repo/testing/trunk/
Index: file1.txt
--- file1.txt   (revision 2)
+++ file1.txt   (revision 3)
@@ -0,0 +1 @@
+Write some dummy test content to the file.

So your current revision that you are working on is '3', lets go back to revision '2', that's before we added the text to 'file1.txt' as pointed out above with the output of '+Write some dummy test content to the file':

user@yourmachine:~/workingcopy/testing/trunk$ svn update -r 2
U    file1.txt
Updated to revision 2.

Now 'file1.txt' will have no content, have a look:

user@yourmachine:~/workingcopy/testing/trunk$ cat file1.txt

If you now want to overwrite your changes on the server within ~/testing/ simply run:

user@yourmachine:~/workingcopy/testing/trunk$ make out

And there you have it. If at any stage you need to change to a particular revision (version) within the repository simply run 'svn update -r NUMBER' and then issue the 'make out' command and your files on the server will be overwritten with that particular revision.

You now have the peace of mind that all your files are under version control. If you are a little more confident with using the version control system now please have a look at this article which goes into a little more detail.