Justin
Justin

Reputation: 45390

Create Git Repo From Sub-Directory In Parent Repo

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.

Upvotes: 1

Views: 183

Answers (1)

inger
inger

Reputation: 20194

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

Upvotes: 2

Related Questions