I’m struggling to understand how to be able to clone a git repository from Subversion, and then clone that repository to another machine (git-to-git) and still have access to all the original Subversion branches and tags. Here’s what I’ve done, and where I’m running into roadblocks.
First, on machine A, I cloned my Subversion repository into a git repository:
[machine A]$ git svn clone -s http://svn.repo.url/MyProject
That gave me a git repository with the entire history and all the branches and tags of my original Subversion repository:
[machine A]$ git branch -r
* master
remotes/v1
remotes/v1.1
remotes/v1.2
remotes/test_migration
remotes/tags/20100104
remotes/tags/20100308
remotes/trunk
Now, on machine B, I want to clone that git repository, and still have access to all the original Subversion branches and tags. First, I cloned the repository:
[machine B]$ git clone machine.a:git/MyProject
This got me a clone of the git repository… but I don’t see any of the remote branches or tags:
[machine B]$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
No matter what form of git checkout --track -b [branch] origin/[branch] I try, I can’t get a branch created on machine B that tracks one of the remote, originally-from-svn branches… nor does a git svn fetch, git svn pull, or anything else I can try pull in the remote branches and tags from the repository on machine A. what am I doing wrong?
I think this is because git doesn’t clone remote branches by default. Configure your clone with this command
before you do the initial
git fetchto clone the original repo. See the docs for details (search for the string above to find the explanation).Also read the section “CAVEAT”. Subversion isn’t git and there are some important differences which you must understand or you will corrupt either your git or your svn repo.