How to git-svn clone the last n revisions from a Subversion repository?
git, git-clone, git-svn, svn, svn-checkout
Solution
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`).
For example: `git svn clone -s -r1450:HEAD some/svn/repo`
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.
Problem
Problem How do you create a shallow copy with git-svn from a Subversion repository, e.g. 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