开发者

Git, pull in part of another repository

开发者 https://www.devze.com 2023-01-22 16:09 出处:网络
Say there are two repositories X and Y with a file structure like below. X-+ |- /A |- /B |- /C Y-+ |- /E |- /F

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'开发者_Go百科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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消