Subversion: Installation and Basic Use

Installing subversion:

saffrongeek@saffrongeek-laptop:/var/www/worksvndemo/drupal$ sudo apt-get install subversion

3 modes of svn setup & use:

svn with ssh=> especially, when the number of users is very few , this is best.

svn with svnserve=> custom server ‘svnserve’ is used when its not necessary to have high security,fine grained access.

svn with webdav=> when many projects and users.


svn architecture pic to help give a feel

Basic Setting up repository and familiarising:-

saffrongeek@saffrongeek-laptop:~$ sudo mkdir /var/svnrepo
saffrongeek@saffrongeek-laptop:~$ ls /var/svnrepo/
saffrongeek@saffrongeek-laptop:~$ svnadmin create /var/svnrepo/

saffrongeek@saffrongeek-laptop:~$ ls /var/svnrepo/
conf  db  format  hooks  locks  README.txt

Note:Recommended layout for a subversion project includes three folders called branches, tags and trunk. Now, @ webroot, I have my project folder wordpress which I would prefer to import to repository.

saffrongeek@saffrongeek-laptop:/var/www$ sudo svn import wordpress/ file:///var/svnrepo/wordpress/trunk -m “Initial import”


Adding         wordpress/wp-admin/themes.php
Adding         wordpress/wp-admin/custom-background.php
Adding         wordpress/wp-feed.php

Committed revision 1.

Now, deleted the project folder from webroot.

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ rm -rf wordpress

checking out

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ svn co file:///var/svnrepo/wordpress/trunk wordpress


A    wordpress/wp-admin/custom-background.php
A    wordpress/wp-feed.php
Checked out revision 1.

After checkout, watever we add folder or files, add the root of the folder added.

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ svn add {foldername}

Any changes reflect on svn after a commit statement

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ svn commit -m “Added folder and text file in it”

Same way, we can delete using ‘delete’ instead of ‘add’ above. Again after delete u have to commit to reflect this on server.

Subversion using svnserve:-

Note: SVN repo is created in my case at /var/svnrepo as u can find from above.

Setting the access rules first:-

Go to /var/svnrepo/conf/ and open svnserve.conf.

Uncomment following in the conf.

anon-access = read
auth-access = write
realm = wordpress
password-db = passwd

saffrongeek@saffrongeek-laptop:/var/svnrepo/conf$ sudo gedit passwd  ( I kept harry:rekha )

svnserve can now be started using => saffrongeek@saffrongeek-laptop:/var/svnrepo/conf$ svnserve -d -r /var/svnrepo/

Note: if u get this error, “svnserve: Can’t bind server socket: Address already in use” all u need to do is make ur attempt to start , asking svnserve to listen to another port. Default is 631.

saffrongeek@saffrongeek-laptop:/var/svnrepo/conf$svnserve -d –listen-port {someportnumber} -r /var/svnrepo/ should resolve bind problem.

I dint find svnserve init script in /etc/init.d/ but this script came handy for me. I took this from internet. note that u can also set crontab.

#File: /etc/init.d/svnserve
. /etc/rc.status
case “$1” in
echo -n “Starting svnserve ”
startproc -u $SVN_UID -g $SVN_GID -e svnserve -d -R -r $REPO_ROOT
rc_status -v
echo -n “Shutting down svnserve ”
killproc -TERM svnserve
rc_status -v
$0 stop
$0 start
echo “Usage: $0 {start|stop|restart}”
exit 1

After this, repo is accessible as svn://username@urlhostname. Also from ur local machine when u make a change and commit it , now since access permissions are defined, commit syntax luks as below

$svn commit -m "Added folder" --username harish
password for 'harish': rekha , pressed enter and it shows status of command execution.

Readable links which could be quite handy and useful:-

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: