If I have a Git repo on a directory say /app1 is it possible to create a sub-repo on a directory /app1/framework, basically I want to keep the framework inside of the parent directory, but I want to be able to clone just the contents of framework.
1 Answer
I assume you don't intend to add files in the subrepo also in the parent repo - that would probably be bad idea (although possible).
Yes, you can create repos under another repo, usually it makes sense to use them as submodules. Generally I find Pro Git book a complete yet friendly source.
In case that looks overwhelming, here's a short summary: Git Submodules Cheatsheet. The extra commands you'll use in practice:
git submodule add pathto/subrepo # to add/link a subrepo(app1/framework to parent one /app1, the first time git submodule update [--init] # if parent repo is shared(clone), where someone else added a submodule [--init: first time after the clone] git commit # an extra commit on parent repo to record the changes in the subrepo 2 Comments
Justin
Wow that is super complicated. I tried just creating a new directory
/framework and then symbolic linking to /apps1/framework but that did'nt work, since that directory is already under source control.inger
If things could be that simple, in probably would be that simple :) Maybe what you find confusing is the snippets in the manpage I first linked - but those are more that just submodule specific commands, they are a full runnable demo starting from scratch.. Just added 2 more links that might clarify things.. But yes, it does take some effort the understand the full story, and that extra complexity is not without purpose.