Speeding up git-svn for several users

Posted: July 9, 2009 in geek stuff

Git-svn is a wonderful tool if you need to access an svn repo. Reading the docs, it discusses how slow the initial clone is and that you should do one clone, check it into git, and have others clone from you. I tried this, doing the following:

$ git svn clone svn://some/project
$ git push git+ssh://mygit.repo

All was good. I then attempted to clone this, and I saw the following:

$ git clone git+ssh://mygit.repo
$ git svn init svn://some/project
$ git svn rebase
Unable to determine upstream SVN information from working tree history

And worse then this, if I did a git-svn fetch it pulled down the entire repo again (4 hours). I am trying to find where in the code the issue is, but here is the workaroung. You need to add one file into the .git repo which points to the current commit’s hash.

# clone the git repo
$ git clone git+ssh://mygit.repo

# Attach it to the svn repo:
$ git svn init svn://some/project

# get the latest commit hash
$ cd mygit.repo
$ git log

# The latest hash will bet the first thing you see (commit [HASH])
# Copy it, and add it as a single line to the git-svn file
$ vi .git/refs/remotes/git-svn

# Now you can fetch the latest from subversion, and begin working
$ git svn fetch
$ git svn rebase 

  1. Fernando says:

    Do you know if it is possible to have one single Git repo talking to SVN upstream, and them have multiple users pushing/pulling to/from this common Git repo?

    I mean, users would interact using regular git commands against the “common” repo, which in turn would push/pull using git-svn (via commit hooks or something).

    • bryankearney says:

      I believe so, if one person were the blessed svn commiter. I believe you and i could collaborate on a git repo, and I could push your and my changes to an svn repo. I do not know if you would get “credit” in the commit list. I do not know if you can set it up to automatically push on each commit.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s