7

I have one GIT repository in a folder called AA, and I have second GIT repository called BB.

I want to import the AA repository into the BB repository as a sub folder.

before:

AA
 |- .git
 |-  A/
 |-  fileA

BB
 |- .git
 |-  B/
 |-  fileB

after:

BB
 |- .git # new .git with both AA and BB .git infos
 |-  B/
 |-  fileB
 |-  AA/      # <== no .git anymore
 |-  AA/A/
 |-  AA/fileA

How can I do that?

rofrol
  • 14,438
  • 7
  • 79
  • 77
Sato
  • 8,192
  • 17
  • 60
  • 115
  • 1
    Is [this](http://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another?rq=1) what you are looking for? – cfi Mar 08 '13 at 10:07
  • Similar but not exact. I have tried solutions mentioned there, folder structure is different. – Sato Mar 08 '13 at 10:11
  • Do you still need the history of AA? – iberbeu Mar 08 '13 at 10:13
  • 3
    Look for "subtree merging". I dont have time to write out a whole answer right now, but that should pretty much get you there, it does exactly what you want. Lets see... maybe [this github article](https://help.github.com/articles/working-with-subtree-merge) will give you some first pointers – Nevik Rehnel Mar 08 '13 at 10:18
  • @NevikRehnel, [subtree merging](https://help.github.com/articles/working-with-subtree-merge) is exactly right. Thanks! – Kaushik Ghose Oct 15 '13 at 18:24

1 Answers1

3

If folder structure is different a git mv would solve that:

  1. Clone the orig repo,
  2. git mv all stuff into a new subdir AA.
  3. Then use that as the source repo to clone from with this answer from this question.
Community
  • 1
  • 1
cfi
  • 10,915
  • 8
  • 57
  • 103