I\'m cheap. I don\'t want to pay for many github accounts.
I have a project structure which looks something like this.
You could use git subtree locally to maintain a git repository which is split from your larger repo
repository, and push from that split repository. Frankly, though, I'd either use one of the free services that Adam Dymitruk suggests or just pay GitHub a bit more - they do provide an excellent service, after all...
This question does not make sense anymore since GitHub now allows users to have unlimited repositories for free, but I will share my knowledge anyways because I think someone could find this interesting.
The thing is that you can have a repository with multiple proyects with no need to create any other repository with git submodule
. Normally, in order to use git submodule you would have to have a repository for each submodule, but I realised that instead of creating a separate repository for each project you want to include in your repository, you can reuse the repository you want to include your projects in, like this:
Create your repository which will contain multiple projects on GitHub.
For the sake of this answer, let's say this repository is at https://github.com/example/example.git
Clone that repository locally:
git clone https://github.com/example/example.git
Create a (preferably orphan) branch for each of the projects you want to have:
git checkout --orphan project_1/master
git commit -m "First commit of project_1/master"
git push --set-upstream origin project_1/master
git checkout --orphan project_2/master
git commit -m "First commit of project_2/master"
git push --set-upstream origin project_2/master
git checkout --orphan project_3/master
git commit -m "First commit of project_3/master"
git push --set-upstream origin project_3/master
Add in branch master a submodule for each of the projects specifying the correct branches:
git checkout master
git submodule add --branch project_1/master -- https://github.com/example/example.git project_1
git submodule add --branch project_2/master -- https://github.com/example/example.git project_2
git submodule add --branch project_3/master -- https://github.com/example/example.git project_3
Commit and push:
git commit -m "Added 3 projects to the repository"
git push
Now you can use each project in this repository as if they were each in it's own repository. However, each time you create a new branch you must create it under the project's branch folder. For instance, if you want to create a branch 'new_feature' in project_1 you must execute this:
git branch 'project_1/new_feature'
And if you want to download a project anywhere else, you can either:
Clone the project itself and nothing else:
git clone --branch project_1 https://github.com/example/example.git ./project_1
Or clone the whole repository if you want to work with multiple projects at the same time, and then download only the contents of the projects you are actually going to work with:
git clone https://github.com/example/example.git
git submodule init project_1 project_3
git submodule update --remote
If you are always going to
git submodule update
with--remote
you might want to also execute this command to stop showing the projects's name when yougit status
from the main repository:git submodule foreach 'git -C $toplevel config --file .gitmodules submodule.$name.ignore all'
feature
you create a branch called project_1/feature
git subtree
: I have understood this tool is created for this specific purpose, but it has some disadvantages and I don't know how to use it.If you want, you could use unfuddle or bitbucket if you don't want to pay anything. Use submodules to host large files such as images, 3rd party dlls, videos, etc on github. These would hold no IP.
This is going to get very unwieldy very quickly (especially as Git won't let you push pull sub directories like svn will)
I would look at not using Github for storing projects. Tools such as Bitbucket or CodebaseHQ have different pricing models which may well fit you better and give you the simplicity you need.
Alternatively, look at something like Gitosis, which can be made to be very Github-esque via tools like Gitlab
how about putting every separate project in a different branch ? it worked fine with me so far. I have a private repo for webProjects and every branch starts with master which has my web projects template (could be empty branch as well) and every time I have new project I just create a master based branch with the project name and cary on working fine.