Moving multiple folders from one subversion repository to another subversion repository

I've a centOS 6.4 server and with subversion 1.4.2 installed. I've two subversion repositories in my server.

I've been using 'repoOLD' for the past two 4 months and now I've created another repo with name 'repoNEW'

'repoOLD' contains 100 folders (projects).

'repoNEW' is just created and I need to copy few projects from 'repoOLD' to 'repoNEW'

Now the problem is how can I transfer multiple folders(projects) from my 'repoOLD' to 'repoNEW'

I've tried googling but I was unable to find tutorials for moving multiple folders from one subversion repository to another repository

  • Do you want to retain the commit history for the folders you move? If yes, that's just the kind of thing that git filter-branch is good at (e.g. for trimming away the commits that don't touch the desired files) but I'm not so sure subversion can do it very well! Also NOTE: I'm going to remove the centos tag as this question really a subversion question that doesn't depend on any particular OS. – Celada Jan 29 '15 at 12:38
  • Yes I want to retain the commit history. – Gangadhar Jannu Jan 29 '15 at 12:40

Someone else may post a better answer that uses Subversion directly, but I'm going to suggest a way that involves converting to git and then back to Subversion, because git's filter-branch feature is good at this.

Clone the old svn repo to a local git repo

git svn clone <url-for-repoOLD>

I'll assume the local git clone is now stored in directory repoOLD

In the git clone, filter out everything you don't want

Now remove everything you don't want anymore in the new repo.

cd repoOLD
git filter-branch --force --index-filter \
    'git rm -r --cached --ignore-unmatch dirA dirB dirC dirD' \
    --prune-empty --tag-name-filter cat -- --all

...where dirA dirB dirC dirD are all of the directories you don't want anymore. You have to list all of the ones you want to remove.

Check this repo with ls and git log and such to make sure it contains what you want.

Clone the new svn repo to a local git repo

cd ..  # (get out of repoOLD if you are still in there)
git svn clone <url-for-repoNEW>

I'll assume the local git clone is now stored in directory repoNEW

I will also assume that repoNEW is completely empty at this point because you haven't committed anything to it or imported anything from repoOLD.

Import everything from the git clone of repoOLD

cd repoNEW
git remote add repoOLD ../repoOLD
git fetch repoOLD
git merge repoOLD/master

Now push those changes back to the repoNEW svn server

git svn dcommit
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.