13 October 2012

I managed two sites in separate repositories, but I eventually decided that the excess complexity was unlikely to prove helpful anytime soon. Having administered subversion for quite some time, and given my low demands for the history accuracy, it was pretty straightforward.

  1. Original setup:
    1. /drive/folder_a -> repo_a (folder_a is the root checkout)
    2. /drive/folder_b -> repo_b (folder_b is the root checkout)
  2. Target setup: The new repo will be relative to the server root ("/") such that folder_a will now be at "drive/folder_a" within the new repo.
  3. Ensure that both folders are fully committed
  4. Create a new master repo: svnadmin create /path/to/repo
  5. Go to a temporary folder (paths below are relative to that directory)
  6. Export the old repos
    1. svnadmin dump /path/to/repo_a > repo_a.repo
    2. svnadmin dump /path/to/repo_b > repo_b.repo
  7. Initialize the new repo
    1. svn co file:///path/to/repo
    2. cd repo
    3. svn mkdir drive drive/folder_a drive/folder_b
    4. svn commit -m "Initialize directory structure for repo merge."
  8. Import the old repos
    1. svnadmin load --parent-dir drive/folder_a/ /path/to/repo < ../repo_a.repo
    2. svnadmin load --parent-dir drive/folder_b/ /path/to/repo < ../repo_b.repo
  9. Update the working copies
    1. Remove the old .svn directories from
      1. rm -rf $(find /drive/folder_a -type d -name .svn)
      2. rm -rf $(find /drive/folder_b -type d -name .svn)
    2. Copy the new .svn directories into place
      1. svn update # to update the temp working copy from just the base directories
      2. find . -type d -name .svn | while read d; do echo $d; cp -rf "$d" "WORKING_COPY_ROOT/$d"; done

All of these commands assume that you are within the temp checkout folder. If you change that, or if your repositories do not share a theoretical parent folder, or if you are not on the same server, then you will likely need to tweak some of the commands.


  1. The version numbers are not mixed together. The version numbers are 0 to X and X+1 to X+Y. It is possible to merge them, but it is more complex and was unnecessary for my use case.
  2. This only addresses your working copy. Other computers with a working copy would need to checkout a new copy. If they want to keep them in place, then they would need to checkout a new version and then update using a modified version of the last steps.

blog comments powered by Disqus