Welcome to End Point’s blog

Ongoing observations by End Point people

Continuing an interrupted git-svn clone

I've run into the issue before when using git-svn to clone a large svn repo; something interrupts the transfer, and you end up having to restart the git-svn clone process again. Attempting to git-svn clone from a partially transferred svn clone directory results in error messages from git-svn, and it's not immediately clear what you need to do to pick the process back up from where you left off.

In the past I've just blown away the partially-transferred repo and started the clone over, but that's a waste of time and server resources, not to mention extremely frustrating, particularly if you're substantially into the clone process.

Fortunately, this is not necessary; just go into your partially retrieved git-svn repo and execute git-svn fetch. This continues fetching the svn revisions from where you left off. When the process completes, you will have empty directory with just the .git directory present. Looking at git status shows all of the project files deleted (oh noes!), however this is just misdirection. At this point, you just need to issue a git reset --hard to check out the files in the HEAD commit.

More illustratively:

$ git svn clone project
# download, download, download, break!
$ cd project; ls -a
$ git svn fetch
# download, download, download, success!
$ ls -a
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#       deleted:    foo.c
#       deleted:    foo.h
$ git reset --hard; ls -a1


Anonymous said...

awesome, exactly what I was looking for!

dpb said...

Awesome, thanks for writing this up!

Jan Tietjens said...

Thank you very much, that was exactly what I needed!

Anonymous said...

You, sir, are a life-saver!
Thank you very much!

magnus said...

Thank you very much! I had 9700 out of 12200 SVN revisions checked out when I got an error because of a missing author in the users.txt. Took 3 hours just to get there so this saved me a lot of time! Cheers!

Anonymous said...

Thanks a lot! I real lifesaver... well more like a "hour-and-a-half-on-extra-hours-in-the-night-at-the-office-and-I-really-need-this-done-because-my-OCD" saver.. but rest assured that would be the same amount of thanks as my life were on the line =D.. happy coding