0

I am migrating SVN to GitHub using git-svn, only migrating the master(trunk) and only including the latest n revisions.The following command might work:

git svn clone -s -r$HeadMinusN:HEAD some/svn/repo

however, instead of manually calculate the revision number by minus HEAD-Revision by N, do I have a way that acts like as the --depth option in git command.

Thanks

  • 2
    Possible duplicate of [How to git-svn clone the last n revisions from a Subversion repository?](https://stackoverflow.com/questions/747075/how-to-git-svn-clone-the-last-n-revisions-from-a-subversion-repository) – phd Dec 11 '18 at 18:50
  • The most interesting part of the accepted answer is: *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.*** – phd Dec 11 '18 at 18:50
  • [This](https://techoverflow.net/2013/02/11/git-svn-clone-latest-revision-only/) article demonstates using `svn info` to find out the last revision. I don't know if it's possible to find out Nth revision with it. You can find revision by date. – phd Dec 11 '18 at 18:52

1 Answers1

0

When permanently migrating a repo from svn to git, one usually wants to either:

  • save all svn history as much as possible (full clone);

  • discard all svn history and record it clearly that you're doing that: git init cp -r ../svn/source/* . git add * git commit -m 'initial import from svn rev12345'

By saving only partial history, you're doing a disservice to anyone who might dig into that history in the future (including, possibly, a future you).

So my answer is: don't make a shallow clone. It's not suiting your use-case.

ulidtko
  • 14,740
  • 10
  • 56
  • 88