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
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