views:

1303

answers:

2

I often have the case that I want to work on a SVN repository right away. But an ordinary git svn clone [url] also clones the entire history. So I want to speed things up. The first part is to fetch only the last revision into your Git repository. I do it like so:

URL=http://google-web-toolkit.googlecode.com/svn/trunk/
REV=`svn info $URL |grep Revision: | awk '{print $2}'`
PROJECT_FOLDER=google-web-toolkit-readonly

git svn clone -r$REV:HEAD $URL $PROJECT_FOLDER

(more info in the StackOverflow article: "How to git-svn clone last n revisions from svn"

This way I'm up and running and can work immediately. But without local copy of the history.

The question is, how do I afterwards fetch history from the svn repository?

And preferably, can this be done in chunks of, say 1000 revisions (in reverse order). Any help here would be greatly appreciated :)

+8  A: 

I found out how it can be done. The trick is not to use git svn clone. Instead, use git svn init and git svn fetch individually. Modified the example:

URL=http://google-web-toolkit.googlecode.com/svn/trunk/
REV=`svn info $URL |grep Revision: | awk '{print $2}'`
PROJECT_FOLDER=google-web-toolkit-readonly

mkdir $PROJECT_FOLDER
cd !$ #goes into dir named $PROJECT_FOLDER
git svn init -s $URL #-s implies --stdlayout with /trunk /tags /branches
git svn fetch -r $REV

# hack, hack, hack

# or update history (fetch 50 revisions back each loop
for (( r=$REV; r>0; r-=50 )); 
do 
  git svn fetch -r $r:HEAD
done
Jesper Rønn-Jensen
this doesn't seem to work for me, it just returns when I try to do git svn fetch -r 1000:HEAD
verhogen
+1  A: 

git svn fetch appears to "remember" the revisions it's seen previously. I've been having success with doing ranges:

git svn fetch -r 0:100 git svn fetch -r 100:200 git svn fetch -r 4500 git svn rebase git svn fetch -r 200:300

I fetched the most recent revisions and then started "filling in" the gaps. It seems to work fine.

Jesper -- if your repository doesn't have a revision 1000, then there's nothing for it to fetch. Make sure the revision numbers you're using are valid!

Rob Crawford