Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having multiple 'sub-repositories' in one git repository?

Tags:

git

github

I was fortunate enough to obtain a free micro-plan Github account to use for my schoolwork through Github's EDU program. However, I am not sure how best to structure this for my CS classes. Ideally, I would have a different repository for each class -- CS101, CS102, etc. However, the micro-plan only allows up to 5 repositories, and I will be taking more than 5 classes within the next year or two. So, is there a way to structure one repository to keep commits 'separate' for each folder, i.e. have one repository with multiple 'sub'-repositories (basically a submodule).

Any advice is appreciated.

Thanks!

like image 282
user1516425 Avatar asked Jul 26 '12 00:07

user1516425


People also ask

Can you have multiple repositories in Git?

With Git, using multiple repositories is the only way to work efficiently. This enables each team to work independently, and do their work faster. You can also make sure that developers only have access to the repositories they need access to (thus making Git more secure.)

Can you have sub repositories on 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 you have multiple projects in one repository?

Yes. You can put multiple projects in one Git repository but they would need to be on different branches within that repo. The Git console in ReadyAPI gives you the ability to create or switch branches from the UI.


1 Answers

Branching

For each class, run within the repository git checkout --orphan <classname>, and you can get a new parentless branch for that class's content.

When getting local copies of your repository, run git clone --single-branch --branch <classname> <url> <localdir>, and it will only clone and later fetch that class's branch.

Bitbucket

As trauzti said, I would definitely recommend a Bitbucket account. While the UI isn't as pretty as Github's, it has all the same functionality, and they do allow free unlimited private repositories. I use it for my schoolwork. If you really want to use Github though, then the above would work.

like image 101
vergenzt Avatar answered Sep 28 '22 09:09

vergenzt