Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add one git repository into another git repository's sub-folder?

Tags:

git

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?

like image 913
Sato Avatar asked Mar 08 '13 10:03

Sato


People also ask

Can you put a Git repository inside another Git repository?

Git addresses this issue using submodules. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.


1 Answers

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.
like image 119
cfi Avatar answered Oct 06 '22 19:10

cfi