Bernhard Vallant
Bernhard Vallant

Reputation: 50786

Checking out only a subdirectory of another repo with git-submodule

I need to only add a part (a directory) of another project within my "superproject", so I'd like to know if it is possible with git-submodule to only add a certain directory from another repository to my project?

(I'm using git for the deployment as well, so I do not want to stuff my project with other unnecessary things.)

Upvotes: 3

Views: 959

Answers (1)

Adam Dymitruk
Adam Dymitruk

Reputation: 129566

You could make a bare repo and then just use git checkout with the --work-tree and --git-dir parameter after the git command and specify the branch/tag you want and then specify the path you want after the -- file specifier option. Example:

git --git-dir=somedir --work-tree=someotherdir checkout somebranchortag -- somepath

Hope this helps.

Upvotes: 1

Related Questions