Merging SVN repos while retaining history

Here is a quick little how-to on merging separate Subversion (SVN) repositories into one, while keeping the history in tact. Note that the checkin ID's will change, but you do have a little control over how Subversion will show the change logs.

For this tutorial, we want to merge:

old1, old2, old3 and old4

into a new single repository called


First you will need to create a temporary directory to do the work in. You must have enough space in this directory to handle at least two times the current size of your repository.

We will, for the purposes of this Subversion Tutorial, be working in /home/temp/.

cd /home/temp
mkdir svnworking

Now lets move over to our subversion repository and create the new repository that will house our final merged repository:

cd /home/vhost/home/svn/repositories
svnadmin create newrepos
chown -R apache: newrepos

The next step is to create root folders in our new 'newrepo' SVN repository. You want to create one new root folder for each repository that you will be merging in:

svn mkdir -m "Initial project Root Folders" \
file://home/vhost/home/svn/repositories/newrepo/old1 \
file://home/vhost/home/svn/repositories/newrepo/old2 \
file://home/vhost/home/svn/repositories/newrepo/old3 \

Note: the backslashes are there to allow me to split command onto separate lines. If you plan on putting the command to create the root repos onto one line, then don't use the backslashes.

The next step is to disable Subversion, which will vary depending on how you have it setup. Once the SVN repository is turned off, we are ready to dump the contents of all our Subversion repositories to our temporary location we created above.

svnadmin dump old1 > /home/temp/svnworking/old1.repos
svnadmin dump old2 > /home/temp/svnworking/old2.repos
svnadmin dump old3 > /home/temp/svnworking/old3.repos
svnadmin dump old4 > /home/temp/svnworking/old4.repos

Depending on how large your repositories are, the dumping process could take awhile to process. Once it is complete, the last step is to simply reload your dumped repositories in the order that you want to maintain the update messages.

In your old repositories you theoretically had each repository check-in number starting at 1 and sequentially going up from there. When you remerge the repositories, you can only have a single first check-in. In our example we will re-merge the repositories in this order: old1, old4, old2 and finally old3. Lets assume for a moment that old1 had 100 check-ins, old2 had 54 check-ins, old3 had 1004 check-ins and old4 had 5 check-ins.

Once our merger is complete our check-in numbers will now go like this:

old1 will start at 1 and finish at 100.
old4 will start at 101 and finish at 105
old2 will start at 106 and finish at 159
old3 will start at 160 and finish at 1163

svnadmin load /home/vhost/home/svn/repositories/newrepos --parent-dir old1 < /home/temp/svnworking/old1.repos
svnadmin load /home/vhost/home/svn/repositories/newrepos --parent-dir old4 < /home/temp/svnworking/old4.repos
svnadmin load /home/vhost/home/svn/repositories/newrepos --parent-dir old2 < /home/temp/svnworking/old2.repos
svnadmin load /home/vhost/home/svn/repositories/newrepos --parent-dir old3 < /home/temp/svnworking/old3.repos

Feel free to ask questions or suggest modifications to my method posted here. Due to my schedule I may not be able to respond very quickly. If you require further assistance right away with your Subversion Repositories, please visit