Git, pull in part of another repository

git, version-control

Solution

You can do this with symlinks and git submodules: http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/

Note you still have to pull in the whole project tree as a submodule so if you are trying to save space, this won't help and you'll need some other solution.

For example (this assumes a *nix system), inside project Y:

mkdir .include
git submodule add git@mygithost:X .include/X
ln -sf .include/X/B F

Problem

Say there are two repositories X and Y with a file structure like below. ``` X-+ |- /A |- /B |- /C Y-+ |- /E |- /F |- /G ``` I know it's possible to pull X into Y and git will merge the files. Is it possible to pull directory B into directory F of repository Y? I'm guessing it isn't because git doesn't track directories. Is it possible to achieve this with git in some other way?

Original source