views:

461

answers:

5

Can I nest git repositories? I have:

 /project_root/
 /project_root/my_project
 /project_root/third_party_git_repository_used_by_my_project

Does it make sense to git init/add the /project_root to ease management of everything locally or do I have to manage my_project and the 3rd party one separately?

+1  A: 

I would use one repository per project. That way, the history becomes easier to browse through.

I would also check the version of the third party library I'm using, into the repository of the project using it.

gnud
+10  A: 

You may be looking for the Git feature called submodules. This feature helps you manage dependent repositories that are nested inside your main repository.

Greg Hewgill
Perfect, that's exactly what I was looking for.
Jeremy Raymond
A: 

This looks like a job for git submodules. That's the term of art, starting from there you should be able to find what you need. I'm not an expert, so I won't either post a link to a tutorial I can't vet or insult your intelligence.

bmargulies
"Google for it" isn't a valuable answer. Vet it or refrain from answering.
toolbear74
+3  A: 

Place your third party libraries in a separate repository and use submodules to associate them with the main project. Here is a walk-through:

http://book.git-scm.com/5%5Fsubmodules.html

In deciding how to segment a repo I would usually decide based on how often I would modify them. If it is a third-party library and only changes you are making to it is upgrading to a newer version then you should definitely separate it from the main project.

Igor Zevaka
+2  A: 

git-subtree will help you work with multiple projects in a single tree and keep separable history for them.

ephemient