Search code examples
gitsvnversion-controlgit-svngit-clone

Clone a specific svn branch alone into git with the version history for that branch alone


I have a massive svn repository with trunk and multiple branches. I want to clone one specific branch, the most recent one alone into a git repo. I do not want the revision history for the whole svn repository but only from the time the branch was created. my svn repo have a standard structure, like branches,tags and trunk. I tried cloning a specific repo using the command similar to

git svn clone https://{path to SVN repo}/branches/{my branch name}  

This works but considering how huge my repo is, the process is taking at-least a week if I leave my machine running non stop. I figured this is because, GIT is trying to get the version history from the very first commit into the repo. I wanted to check if it would be possible to clone just one branch into GIT with the version history for that branch alone? Sorry for the long question and any help would be appreciated.

When I try the solution using the --single-branch command I get an unknown command error. I assumed since I am using the GIT-SVN bridge, there might be a different command?


Solution

  • I finally managed to do this by making git think that the remote branch is my trunk. That way, I was able to create repo with only revision history from that branch alone.

    git svn clone -T branches/somefeature http://example.com/PROJECT
    

    I used the following URL for reference

    https://gist.github.com/trodrigues/1023167