# Copying files and keeping the history

3 messages from 2009-06-11 to 2009-06-12. Participants: JörgenHägg, Sverre Rabbelier, Avery Pennarun.
Thread: https://gitlist.dev/t/19775

## JörgenHägg, 2009-06-11 13:20

Subject: Copying files and keeping the history
Message-ID: <18567.1244726405@zev.se.axis.com>
URL: https://gitlist.dev/e/18567.1244726405%40zev.se.axis.com

```

I have two completely different git repositories, A and B.

I want to move a file from repo A to B without losing the files history.
That is, I want the commit message and all other info from
each commit where the file was included to generate new
commits in repo B.
(Yes, I know git manages content, not files. :-)

In other words, export a bunch of commits, filtering out the
patches for the file and import these in another repo.

Sort of importing from cvs to git, only the source and destination
are both git repositories.

I tried tailor from git to git, but that was probably not what tailor
wanted to do. :-)

Is this somehow possible?


```

## Sverre Rabbelier, 2009-06-11 18:29

Subject: Re: Copying files and keeping the history
Message-ID: <fabb9a1e0906111129x53a6d90p15a97d958a2d2f63@mail.gmail.com>
URL: https://gitlist.dev/e/fabb9a1e0906111129x53a6d90p15a97d958a2d2f63%40mail.gmail.com
In-Reply-To: <18567.1244726405@zev.se.axis.com>

```
Heya,

On Thu, Jun 11, 2009 at 15:20, JörgenHägg<jorgen.hagg@axis.com> wrote:
> Is this somehow possible?

Try git filter-branch to get just the commits you want and nudge them
to contain what you want (do this in a seperate branch/copy of
repository A). When you're done, pull the branch into B and merge it.
Instant win?

-- 
Cheers,

Sverre Rabbelier

```

## Avery Pennarun, 2009-06-12 03:44

Subject: Re: Copying files and keeping the history
Message-ID: <32541b130906112044m7cf2c0e9s2ba4815a31e534a@mail.gmail.com>
URL: https://gitlist.dev/e/32541b130906112044m7cf2c0e9s2ba4815a31e534a%40mail.gmail.com
In-Reply-To: <fabb9a1e0906111129x53a6d90p15a97d958a2d2f63@mail.gmail.com>

```
On Thu, Jun 11, 2009 at 2:29 PM, Sverre Rabbelier<srabbelier@gmail.com> wrote:
> On Thu, Jun 11, 2009 at 15:20, JörgenHägg<jorgen.hagg@axis.com> wrote:
>> Is this somehow possible?
>
> Try git filter-branch to get just the commits you want and nudge them
> to contain what you want (do this in a seperate branch/copy of
> repository A). When you're done, pull the branch into B and merge it.
> Instant win?

You could also consider 'git subtree'
(http://github.com/apenwarr/git-subtree) to merge the other tree
(including its history) in as a subdirectory.

Avery

```
