# patches between different repositories

2 messages from 2010-05-03 to 2010-05-03. Participants: Matthias Lehmann, Dmitrijs Ledkovs.
Thread: https://gitlist.dev/t/23682

## Matthias Lehmann, 2010-05-03 17:47

Subject: patches between different repositories
Message-ID: <hrn27j$e3b$1@dough.gmane.org>
URL: https://gitlist.dev/e/hrn27j%24e3b%241%40dough.gmane.org

```
Hi all,

I have to apply patches from one repository to another repository, which 
have a different layout (I am working on splitting one big repository into 
several smaller ones, while development still continues on the big 
repository).

So I did

big-repo$ git format-patche -o /tmp/foo @{some-date} -- subdir
small-repo$ git apply -p2 --directory=some/path --check /tmp/foo/*

and get

fatal: git diff header lacks filename information when removing 2 leading 
pathname components (line 37)

the patch looks like this:

35| diff --git a/xyz/bar.jpg b/xyz/bar.jpg
36| new file mode 100644
37| index 0000000000000000000000000000000000000000.. 
3dcce2e1f68586ed2089d86b1bf4e7e41c818d97
38| GIT binary patch
39| literal 8791

It seems, like the -p options to git-apply can't handle new files.

Am I doing something wrong here? Or is there another way to merge changes 
within different repositories with differnt layouts?

Any help would be greatly appreciated.

Best regards,

Matthias

```

## Dmitrijs Ledkovs, 2010-05-03 18:04

Subject: Re: patches between different repositories
Message-ID: <q2x86ecb3c71005031104xff08ab8am9a14bb49ebcd154f@mail.gmail.com>
URL: https://gitlist.dev/e/q2x86ecb3c71005031104xff08ab8am9a14bb49ebcd154f%40mail.gmail.com
In-Reply-To: <hrn27j$e3b$1@dough.gmane.org>

```
On 3 May 2010 18:47, Matthias Lehmann <mat@matlehmann.de> wrote:
> Am I doing something wrong here? Or is there another way to merge changes
> within different repositories with differnt layouts?
>
> Any help would be greatly appreciated.

Try sub-tree merge after the initial setup you will get another
repository as a subdirectory after that you can commit moving files
around to match different layout. After that you can just pull & merge
and everything will just work =)

Read $ git help merge

```
