Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git repository within Git repository [duplicate]

I have a main git repository A and we are using sources out of another git repository B in a subdirectory of our main project. Now it would be good to have the B repository checked out within the A repository in this used subdirectory. If someone else then clones the repository of course he should get our main repository A and within that automatically the B repository.

Let me visualize the directory structure:

 + main_repository       - the root directory of the main Repository   + src                 - directory containing the source      + foreignRepo       - this should be the root directory of another git repo   + binaries   + other 

This must be also known in the remote repository, just a local copy doesn't help me, because other people check this out and must be able to compile all the stuff.

like image 554
Buuuh Avatar asked Dec 21 '10 14:12

Buuuh


People also ask

Can you have a Git repo within a Git repo?

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.

Can I clone a repo inside a repo?

Just for the record, you can clone a git repo within another one: Everything under your lib directory will be ignored by the enclosing Git repo, because said lib directory contains a . git . That means cloning the enclosing repo, and you will get an empty " lib/ " folder.

Can you create a repository within a repository?

So you can just add a repo within your repo and work on it. You might have to ignore the inner repo folder pychargify however. Submodules are needed when you want to share the repo with others who will be cloning it etc.

Can I have nested Git repositories?

Git allows you to include other Git repositories called submodules into a repository. This allows you to track changes in several repositories via a central one. Submodules are Git repositories nested inside a parent Git repository at a specific path in the parent repository's working directory.


1 Answers

You'll want to read about Git submodules.

like image 76
Adrian Petrescu Avatar answered Oct 07 '22 18:10

Adrian Petrescu