Izzo
Izzo

Reputation: 4928

How can I reference a Git monorepo file from another Git repo?

I am currently trying to migrate an SVN repo into several Git repos. The original SVN repo can be interpreted as a monorepo since it features several independent projects. Due to Git tagging, I would like to break up this SVN monorepo into a Git monorepo and several project-specifc repos. Here is my scenario:

I have a Git monorepo call Libraries. This monorepo contains several single file libraries that are relatively independent from one another and hence need to be tagged seperately. Think of it something like

Libraries
    math.h
    math.c
    file.h
    file.c
    ...

Since I consider this a monorepo, I will tag in the following manner

math/1.0.0
math/1.1.0
file/1.0.0
file/1.1.0

Now onto the project specific repos.

I have a repo called Project 1 that needs to reference individual files from the Libraries repo. Complicating the matter, I need to inject these library files into specific directories within Project 1. Something like the following:

Project 1
    headers
        math.h    // from math/1.0.0
        file.h    // from file/1.1.0
        project.h // project specific file
    source
        math.c    // from math/1.0.0
        file.c    // from file/1.1.0
        project.c // project specific file

So essentially I want the project specific repo to reference tagged individual files from a monorepo and I need to place them within very specific directories in the project specific repo.

Can I achieve this using submodules?

Upvotes: 1

Views: 376

Answers (1)

VonC
VonC

Reputation: 1327184

A submodule always means a subfolder in the parent repository.

If you OS supports it, you can then version symlinks for those files between:

  • the specific folders
  • the library submodule folder.

This is assuling you don't have too many of those files to symlink.

Upvotes: 1

Related Questions