Git repository within Git repository

Buuuh picture Buuuh · Dec 21, 2010 · Viewed 30k times · Source

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.

Answer

Adrian Petrescu picture Adrian Petrescu · Dec 21, 2010

You'll want to read about Git submodules.