tags:

views:

6117

answers:

3

Problem

How do you create a shallow copy with git-svn from a Subversion repository, i.e. how do you pull only the last three revisions?

The git clone command can get the last n revisions from a Git repository if you use the option --depth, i.e. you get a shallow copy of the repository. Example:

git clone --depth 3 git://some/repo myshallowcopyrepo

Is there a similar option for git-svn?

My discoveries so far

So far I've only found the -rN option where N is the revision to pull. Example:

git svn clone -rN svn://some/repo

According to the documentation there is the possibility to use -r$REVNUMBER:HEAD. I tried the following to get the last 3 revisions which returned an error message.

$ git svn clone --prefix=svn/ -s -rHEAD~3:HEAD http://some/svn/repo .
revision argument: HEAD~3:HEAD not understood by git-svn

So I replaced HEAD~3 with the actual number of the third but last revision 534. That worked, but that requires me to first figure out the revision number of the third but last commit.

$ git svn clone --prefix=svn/ -s -r534:HEAD http://some/svn/repo .

Documentation

git-clone

git-svn

+15  A: 

You've already discovered the simplest way to specify a shallow clone in Git-SVN, by specifying the SVN revision number that you want to start your clone at ( -r$REV:HEAD).

Git's data structure is based on pointers in a directed acyclic graph (DAG), which makes it trivial to walk back n commits. But in SVN ( and therefore in Git-SVN) you will have to find the revision number yourself.

Paul
+5  A: 

I find myself using the following often to get a limited number of revisions out of our huge subversion tree (we're soon reaching svn revision 35000).

# checkout a specific revision
git svn clone -r N svn://some/repo/branch/some-branch
# enter it and get all commits since revision 'N'
cd some-branch
git svn rebase

And a good way to find out where a branch started is to do a svn log it and find the first one on the branch (the last one listed when doing):

svn log --stop-on-copy svn://some/repo/branch/some-branch

So far I have not really found the hassle worth it in tracking all branches. It takes too much time to clone and svn and git don't work together as good as I would like. I tend to create patch files and apply them on the git clone of another svn branch.

Christian
A: 

It's only about doing svn info yourrepo to get the latest revision, isn't it?

lethalman