Re: Move some files, with all history, from one project into a new one

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 15, 2020 at 8:49 AM Taylor Blau <me@xxxxxxxxxxxx> wrote:
>
> On Wed, Apr 15, 2020 at 11:11:28AM -0400, Jeff King wrote:
> > On Wed, Apr 15, 2020 at 08:31:35AM +0000, Kerry, Richard wrote:
> >
> > > I would like to move some files, from the project in which they have
> > > always resided into  a new project.  I would like to keep all their
> > > history.  I don't want to waste space by also moving the rest of the
> > > old project's history, or historical file contents.
> >
> > Try git-filter-branch's --subdirectory repository, which is designed to
> > do exactly this.
> >
> > Or the much newer (and faster) git-filter-repo:
> >
> >   https://github.com/newren/git-filter-repo
>
> For what it's worth, Elijah has provided some excellent documentation on
> how to use git-filter-repo to do exactly this here:
>
>   https://github.com/newren/git-filter-repo#solving-this-with-filter-repo

That particular example might be for a different case than what
Richard requested, though.  Let's say the original repo had a file
structure like the following:

   module/
      foo.c
      bar.c
   otherDir/
      blah.config
      stuff.txt
   zebra.jpg

If the request is to e.g. take module/ and all files within it with
their history and make a new repository out of it, with module/ being
remapped to the root of the repository, then you would want:
   git filtrer-repo --subdirectory-filter module
and yes, this looks exactly like filter-branch; that's the one flag I
copied from it.  So this one usecase maps directly between the two
tools.

In contrast, if you wanted to keep all files from the original repo
but move everything into a subdirectory named "myProject" (so that
e.g. module/foo.c became myProject/module/foo.c), possibly in
preparation for merging your repo into some larger monorepo, then
you'd want to pass `--to-subdirectory-filter myProject` as in the link
you pointed out.  filter-branch doesn't have an equivalent.


Hope that helps,
Elijah



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux