# How to import a exist git repository into another git repository?

2 messages from 2011-01-05 to 2011-01-05. Participants: Edmond Halley, Andrew Garber.
Thread: https://gitlist.dev/t/26199

## Edmond Halley, 2011-01-05 06:50

Subject: How to import a exist git repository into another git repository?
Message-ID: <AANLkTi=ahqFz=NVMrhtf+u2fJR_PAW-vcXgNYcce=2R+@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DahqFz%3DNVMrhtf%2Bu2fJR_PAW-vcXgNYcce%3D2R%2B%40mail.gmail.com

```
Hi,

I have two exit repos A and B. I would like A becomes part of B. For example:
original:
A
|-- a.cpp
`-- Makefile

B
|-- b.cpp
`-- Makefile

combined:
B
|-- b.cpp
|-- Makefile
`-- A
    |-- a.cpp
    `-- Makefile

The git log of repo A is kept in the combined repo.

I try google but the following methods turn out they do not work like
what I want. I can not view the log of original repo A after
combining.
1) http://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another
Fail at the following command.
git checkout -b ZZZ other/master
error: Untracked working tree file 'Makefile' would be overwritten by merge.

2) http://thread.gmane.org/gmane.comp.version-control.git/5126/
git log only give the lastest commit message. I do not know how to get
the log if orignal repo A.

Thank you!

Best regards,
Halley

```

## Andrew Garber, 2011-01-05 07:02

Subject: Re: How to import a exist git repository into another git repository?
Message-ID: <AANLkTin=AdUYEj8CJ=+YMROFh3BWhn4A+AeL+8fxkuoa@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTin%3DAdUYEj8CJ%3D%2BYMROFh3BWhn4A%2BAeL%2B8fxkuoa%40mail.gmail.com
In-Reply-To: <AANLkTi=ahqFz=NVMrhtf+u2fJR_PAW-vcXgNYcce=2R+@mail.gmail.com>

```
What you're looking for is subtree merge:

http://progit.org/book/ch6-7.html

http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html

- Andrew Garber

On Tue, Jan 4, 2011 at 10:50 PM, Edmond Halley <halleyinvent@gmail.com> wrote:
> Hi,
>
> I have two exit repos A and B. I would like A becomes part of B. For example:
> original:
> A
> |-- a.cpp
> `-- Makefile
>
> B
> |-- b.cpp
> `-- Makefile
>
> combined:
> B
> |-- b.cpp
> |-- Makefile
> `-- A
>    |-- a.cpp
>    `-- Makefile
>
> The git log of repo A is kept in the combined repo.
>
> I try google but the following methods turn out they do not work like
> what I want. I can not view the log of original repo A after
> combining.
> 1) http://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another
> Fail at the following command.
> git checkout -b ZZZ other/master
> error: Untracked working tree file 'Makefile' would be overwritten by merge.
>
> 2) http://thread.gmane.org/gmane.comp.version-control.git/5126/
> git log only give the lastest commit message. I do not know how to get
> the log if orignal repo A.
>
> Thank you!
>
> Best regards,
> Halley
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```
