Reputation: 518
Scenario: In our MainProject, we have more than 12 SubProjects. Some team members works on all SubProjects, Some team members woks on 2-3 SubProjects and Some team members woks only on one SubProject.
Git Repo Strucure: We have created a main repository MainProject.git
. And under it we have added different submodules for different projects, say SP1, SP2,...,SP12
.
Problem: Now when any team member clones MainProject, empty directories of all SubProjects are cloned. What we want is, clone only specific submodules which are required for user and don't even want an empty folder.
How is it possible in git
?
Upvotes: 1
Views: 254
Reputation: 1547
clone only specific submodules
This is possible. After cloning, try:
git submodule init
git submodule update <path to specific submodule>
don't even want an empty folder
I don't think this is possible since the submodule folder is a part of superProject repo.
Try git ls-files
to verify this.
And since we can only clone whole repository, empty folders will get created.
what if someone deleted empty folder
There are two options:
.gitignore
but that is not advisable (See Do you ignore a git submodule in your .gitignore or commit it to your repo?). The developer working on particular sub module would then have to remove the line before working on it. (Then the developers have to be careful not to push edited .gitignore
, hence this doesn't solve the original problem of developers working carelessly)pre-commit
git hook
to restrict people from deleting foldersUpvotes: 2