Working with SVN (Subversion)

svn or Subversion is a kind of repository. And the repository is a kind of file server. But the special thing with the svn is that it remembers every change ever written to it-every change to every file, and even changes to the directory tree itself, such as addition, deletion, and rearrangement of files and directories.

How to check whether SVN is already there in your linux system or not?

Most of the linux OS may already have the SVN. Check into the /usr/bin/ directory. e.g. ls svn*. If it is installed, then you will find the following components of the SVN.

  1. svn: The command-line client program.
  2. svnadmin: A tool for creating, tweaking, or repairing a Subversion repository
  3. svndumpfilter: A program for filtering Subversion repository dump streams
  4. svnlook: A tool for directly inspecting a Subversion repository
  5. svnserve: A custom standalone program, runnable as a daemon process or invokable by SSH; another way to make your repository available to others over network.
  6. svnsync: A program for incrementally mirroring one repository to another over a network
  7. svnversion: A program for reporting the state (in terms of revision of the items present) of a working copy.

Quick Start

(1) Subversion stores all data in a central repository. First of all create a new repository.

This command creates the new repository in the directory /var/svn/myproject/repos. By default it will use the Berkeley DB as the back-end. But the BIG problem with the Berkeley DB is that it crashes frequently(Very bad experience with me, it almostly crashed 4 to 5 time daily). Its better if you try FSFS(another option available) as the back-end. Currently we using FSFS as the back-end and not seen any problem till now. At least it do not crash like Berkeley DB. So while creating the repository you can specially mention which back-end you want.

The above command will create an FSFS-backed repository.

The above command will create a Berkeley-DB-backed repository

Following directories will be created in the /var/svn/myproject/repos directory:
conf, dav, db, format, hooks, locks, README.txt Details of the directory:

Note: Do not create any directory in the repos directory using mkdir command. And be careful in creating permissions and ownership (user, group and other).

(2) Now create a group of users.

Here is myproject_developers is the name of the group.

(3) Now add the users to the group.
To add a new user(not already existing) ‘sony’ to group myproject_developers use following command:

To add existing user ‘mony’ to myproject_developers group use the following command:

(4) Now define the owner and group owner of the directories db and myproject. In my case following would be the view of permissions and the ownership. The is the view of the directory /var/svn/myproject/repos:

The following is the view of the directory /var/svn/myproject/repos/db:

You can see that the owner of the directories and files are root and the group owner is myproject_developers. This is typical example that I have used. But whatever you do, be careful in permissions and ownership.

(5) Now you may would like to import some existing projects to the repository.

In the above command myproject is in the current directory, the content of which you want to import.

(6) Starting the svn server if it is not already running.

The above command will expose all the repository to be accessed from outside.
By default server listens on the port 3690.

(7) Now it is all set on the server side.

(8) Now how to checkout the working copy of the specific project repository?

The above is the way for manual checkout. This will bring out the working copy from the repository. Other way is to use any other client. For eclipse users, plugin is available at:
Installing subversion plug-in on Eclipse : The other popular client is tortoise.

Suppose you are using Berkeley DB and it crashed, so in that case how to recover the SVN Repository?

After recovery permissions of some file may change. So again run the following commands:

Note: Avoid using Berkeley DB, if you can and instead use FSFS as the back-end.


Suppose you are using eclipse and while connecting to svn you get the following exception:

Solution: In eclipse menu go to windows –> preferences –> team –> SVN. Now, in the SVN interface portion select SVNKit (Pure Java), if it is not already selected. Then apply the changes and click on OK to complete the process. Now retry.


References / Further Study

Working with SVN Repository in Eclipse

1 Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Fork me on GitHub