Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create nested repositories in GitHub?

Tags:

I am able to create a repository via https://github.com/ (say repo) and have:

https://github.com/username/repo.git 

How do I create another repository (say sub_repo) placed under repo and expectedly have:

https://github.com/username/repo/sub_repo.git 
like image 872
SparkAndShine Avatar asked Jan 27 '16 17:01

SparkAndShine


People also ask

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.

Can I create sub repository in GitHub?

GitHub does not allow nested repositories (IIRC Git doesn't allow this for bare repositories). However, you can use submodules to nest repositories on the "client side" in the working tree. You need to clone the parent directory.

Can I arrange repositories into folders on GitHub?

On GitHub itself, you cannot group your repos by "folder", unless you create organizations. See SublimeText, for instance, as a group of all sublimeText packages repos. But that won't support a nested folder organization. For now (June 2017), that only supports a nested team organization structure.


1 Answers

GitHub does not allow nested repositories (IIRC Git doesn't allow this for bare repositories).

However, you can use submodules to nest repositories on the "client side" in the working tree.

You need to clone the parent directory.

Then, add the sub-repository as a submodule:

git submodule add https://github.com/username/sub_repo.git 

The sub_repo module will then be linked to the parent repo and can be found in the sub_repo directory.

Commit (.gitmodules and sub_repo), push and you're done.

like image 79
MrTux Avatar answered Jan 01 '23 20:01

MrTux