2

I'm trying to use this command to pull the last 100 revisions from an SVN repo into a local git repo (on Windows).

git svn clone http://... -r 100

For some reason, the resulting checkout is empty other than the .git folder.

But without the -r parameter it works fine (although checks out everything since the dawn of time).

Does anyone know what's happening?

Thanks!

1
  • I assume, in svn, -r is not "the last 100 revisions", but revision number 100. You can check what the current revision number is, subtract 100, and checkout -r (that number):HEAD. Partial mirrors are generally not recommended though. Commented Jan 30, 2014 at 13:03

2 Answers 2

5

With git svn, the -r parameter refers to the revision number in SVN, not the desired number of revisions.

This excerpt from the 'git help svn' command shows the following description of the -r option:

   -r <arg>, --revision <arg>
       Used with the fetch command.

       This allows revision ranges for partial/cauterized history to be supported. $NUMBER, $NUMBER1:$NUMBER2 (numeric ranges),
       $NUMBER:HEAD, and BASE:$NUMBER are all supported.

       This can allow you to make partial mirrors when running fetch; but is generally not recommended because history will be skipped
       and lost.

In your case, you would need to find the most recent revision of your SVN repository and subtract 100 from this to find the starting revision for your clone. You should also explicitly define HEAD as the final revision (since it is also possible to clone only a subsets of the revision history).

So in your case, work out what the starting revision number is ($rev) and run a command like:

git svn clone -r $rev:HEAD http://...

Or if you just want the most recent revision without fetching any revision history:

git svn clone -r HEAD http://...

Note: you can also use the -s option to specify a standard trunk/branches/tags layout for your SVN repository, however this really only makes sense if you clone the entire repository history. When working with SVN branches I find it more effective to just clone the repository starting from the branch you are interested in. For example:

git svn clone -r HEAD http://.../branches/mybranch
Sign up to request clarification or add additional context in comments.

1 Comment

Just for the record, I had a similar problem, and while using -r 100 or -r 100:HEAD didn't help, -r HEAD did the trick for some reason. Thanks.
0

The recommended command would be:

git svn clone -s -r rev:HEAD your_svn_server

-s is important because it is adhere to the svn recommended layout for repositories (which are usually tags, trunk, and branches).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.