Search code examples
gitgit-branchgit-svn

git svn only use branches without trunk or tags


I have an SVN repo with a normal trunk/branches/tags layout. For my git I want to ignore the trunk & tags folder. I just want to have the branches as git branches nothing more.

Folders:

/trunk (empty)
/tags (full of stuff I want to ignore)
/branches/folder1
/branches/folder2

I tried simply cloning the svn using

git svn clone [REPO] -stdlayout

Unfortunately my client has not commited anything into the trunk so I get the error "refs/remotes/origin/trunk not a valid SHA1" I read that no commit into the trunk results in that error.

My question is: How can I only use the branches folder1 & folder2 to create a new git with said branches.

Thanks, Michael


Solution

  • You obviously don't need --stdlayout which implies trunk, branches and tags. Instead you could specify explicitly what you would like to be fetched from svn. Most probably something like this would work for you:

    git svn init http://svn.apache.org/repos/asf/commons/proper/email --branches=branches/*
    git svn fetch
    

    first command will create a .git/config with svn-remote "svn" section which you can adjust for your needs.