I am looking to migrate my codebase from svn to git. There are too many branches in my svn repo. I only wish to clone couple of branches and merge them together and push it to g
git svn fetch
(and clone
) have --ignore-paths and --include-paths so you can ignore some branches/tags (which are paths in SVN repo) or include only matching branches/tags. So it should be something like
git init from_svn
cd from_svn
git config svn-remote.svn.url "svn://…"
git config svn-remote.svn.include-paths "^/branches/3\." # Include only branches that match name 3.*
git svn fetch svn
I think SubGit tool might be the best solution for your case:
https://subgit.com
It allows translating data from SVN to Git including and excluding any branches/tags or even directories inside, so it's easy to get only those branches you want to have in Git. Say, if you have branches 'branch_1'… 'branch_N', but intend to have in Git only 'branch_3' and 'branch_4' (along with 'trunk'), then you can set SubGit as follows:
[svn]
trunk=trunk:/refs/heads/master
branches=branches/branch_3:/refs/heads/branch_3
branches=branches/branch_4:/refs/heads/branch_4
and only those branches will appear in Git.
SubGit supports continuous two-way mirror between SVN and Git, so it's perfectly possible not only get updates from SVN, but send those from Git, too. It also possible to only get updates from SVN by running import periodically, yet in this case, branches that came from SVN should not be changed in GIt.