Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git nested repos

Tags:

git

github

I have 2 repos, A and B and I want to nest B inside A (add it as a sub folder). I just placed B inside A, but the problem is that when I do any modification on repo B, it's not added or even considered in Reop A.

What change or modification should I do to make it considered as repo A?

Considering that repo A is private and repo B is public on GitHub, would that make any difference also?

like image 937
khelll Avatar asked Oct 22 '09 08:10

khelll


People also ask

Can you have nested git?

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.

What are submodules in git?

A git submodule is a record within a host git repository that points to a specific commit in another external repository. Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.

Can you have a repo inside a repo?

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.


1 Answers

You should implement B as a submodule.

git submodule add git://yourdomain.com/path/to/B path/to/B

Where git://yourdomain.com/path/to/B is the distant path to B.
And path/to/B is the local directory where you want to put it in A.

Then every time you'll clone the repo A, you will have to do a git submodule update. And B will be up to date.

Capistrano manages it automatically if you define the :git_enable_submodules to true.

like image 145
Damien MATHIEU Avatar answered Sep 18 '22 14:09

Damien MATHIEU