glo
glo

Reputation: 1428

How to link a subfolder from one git repository into another?

I have 2 git repositories in following structure.

Repository1 -> src
            |
            -> res


 Repository2 -> src
             |
             -> res

I want to link subfolders in Repository2 to Repository1, so that final folder structure would look something like :

Repository1 -> src -> Repository2src
            |
            -> res -> Repository2res

Is there any way I could do this?

Upvotes: 1

Views: 55

Answers (1)

VonC
VonC

Reputation: 1323383

Not directly with Git, considering even a shallow clone would still involve the Repository2 parent folder (instead of directly its src or res folder).

I would recommend:

  • Repo1 parent repo with Repo2 declared as submodule
  • Two symlinks:
    • Repo1/src/Repository2src pointing to ../Repo2/src
    • Repo2/res/Repository2res pointing to ../Repo2/res

Upvotes: 1

Related Questions