[plt-dev] Transferring "usr" data from svn to git

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Apr 22 23:32:10 EDT 2010

On Apr 22, Carl Eastlund wrote:
> My main question is: once I have something in a git repository, can
> I copy a subtree of one git repository into another, and keep the
> history of that subtree?

Yes -- but the history will not be the same as in the original
repository, of course.  (That is, you'll be able to create a new
repository, but it will have different sha1s.)

> If so, then I can reproduce my svn data in git any way I like now.
> If at any time later I decide I don't like the way I've split it up,
> I can split things further or join things back together, preserving
> history, by copying between repositories.

Good point -- specifically for svn, you will probably want to do this
with some directory: start with your overall repository, filter
anything that does stuff outside of that directory, and make the
result look as if that directory was the root.  This is exactly what
`git filter-branch' does with the `--subdirectory-filter' flag.  From
the man page:

       To rewrite the repository to look as if foodir/ had been its
       project root, and discard all other history:

           git filter-branch --subdirectory-filter foodir -- --all

       Thus you can, e.g., turn a library subdirectory into a
       repository of its own.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.