Subversion: Creating a repository with externals - Step By Step

subersion logo

This is an example of setting up a subversion repository from command line. I will assume you have already installed subversion on your machine. I am using Ubuntu Server 12.04.

Reading through various web resources on the subject can get confusing when you're new to subversion. This step-by-step tutorial will show how I managed to set up a new repository with the branches, tags, and trunk directories; imported the first files and then included an external repository within my project.

The setup:

My repository is located on my local server and is located at /srv/svn/thenomadproject

The directory which I will check it out to is located at /srv/www/thenomadproject.nomad

The external subversion repository to include is located at /srv/svn/libraries/nomad

The folder that will hold the external repository is located at /srv/www/thenomadproject.nomad/libraries   (note: I did not make the any directories under libraries. After I add the external repository, and update the directory, the 'nomad' directory will be created for me.

Step 1 - Create the repository:

I created the directory /srv/svn/thenomadproject It must be empty.

From the command line on my local machine:

svnadmin create /srv/svn/thenomadproject

Now I have a new repository with nothing in it.


Step 2 - Create the directories within the repository:

This could cause confusion because you don't actually create the directories directly, instead you tell subversion to create them in the repository

From the command line on my local machine:

svn mkdir -m "initial setup" file:///srv/svn/thenomadproject/trunk

Resulting in : Committed revision 1.

Repeat for the other directories.

svn mkdir -m "initial setup" file:///srv/svn/thenomadproject/branches

Resulting in : Committed revision 2.

svn mkdir -m "initial setup" file:///srv/svn/thenomadproject/tags

Resulting in : Committed revision 3.


Step 3 - Initial import of files into the repository.

You will need a copy of the files locally. I am using the same directory I plan to use as the checkout directory. I will import the files from my checkout directory, then delete those files and issue the checkout command to the same folder. Another way is to have a temporary directory that holds your initial import files, then you can delete the temp files after the import. I already have my initial files and the folder in which I want to store my external repositories created.

From the command line on my local machine:

Change directories to the directory that has the files I want to import. For me:

cd /srv/www/thenomadproject.nomad

Then issue the subversion command:

svn import -m "initial import" . file:///srv/svn/thenomadproject/trunk

Resulting in a list of files and directories added, and

Committed revision 4.

Now I have a repository ready for checkout.


Step 5 - Checkout repository

In my example, first I must delete the current contents of the directory. If you used a temporary directory, you don't need to delete your checkout location directory contents.

I used a rm -rf command, but feel free to use whatever method you're familiar with.

Next checkout (dont forget the period at the end):

svn checkout file:///srv/svn/thenomadproject/trunk .

Resulting in a list of files and directories that have been added, and

Checked out revision 4.


Step 5 - Include the external repository

Make sure you are in the root of your project. Then issue the svn propset command (don't forget the period at the end):

svn propset svn:externals "libraries file:///srv/svn/libraries/nomad/trunk" .

Resulting in:

property 'svn:externals' set on '.'

Finally, just update your working copy:

svn update



This is how I was able to use subversion from the command line. There are other tools and IDEs that can assist. I personally use phpStorm and it can handle some of this work for me, but I wanted to use the command line to learn how.

Hope this helps you!






Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer