Silver's Simple Site - Weblog - 2015

Cloning a git-svn repository without re-downloading everything

This is a problem I've been having for a few weeks now, since I started using git and the git-svn plug-in to operate on a Subversion repository. Today I figured out the solution.

When you git clone a repository which has been used with Subversion and git-svn, none of the extra metadata is cloned with it. That's expected, so you have to do git svn init again to configure git-svn in this new repository. However, this does not save you from git-svn then downloading everything from Subversion! This can easily take hours, if not days, on a large repository.

The trick is simple enough: git update-ref refs/remotes/git-svn master. Note that you might need to use a different branch name in place of "master", depending on your git repository's set up. All this does is tell git-svn that the latest Subversion commit is the latest git commit on branch "master".

Now when you do git svn fetch, the worst it'll do is "Rebuilding ...rev_map..." which should only take a minute or two and is entirely local.

$ git clone
normal clone stuff

$ git svn init

$ git update-ref refs/remotes/git-svn master

$ git svn fetch
Rebuilding .git/svn/refs/remotes/git-svn/.rev-map.guid ...
r1 = sha1
Done rebuilding .git/svn/refs/remotes/git-svn/.rev-map.guid


Permalink | Author: | Tags: Git, Subversion, Version control | Posted: 08:45PM on Tuesday, 22 December, 2015 | Comments: 0

Powered by the Content Parser System, copyright 2002 - 2017 James G. Ross.