0

I have few repos that requre same files in each. I discovered that I can use git submodules to do it but I got stuck.

Let's say this is a file structure in each of my projects:

MainCatalog/

  1. CatalogA (contains some files)
  2. CatalogB (contains some files)
  3. CatalogC (contains some files)
  4. File1
  5. File2
  6. ...

And with that structure I'd like to use a submodule for two catalogs (CatalogA and CatalogB) Is it possible? Or should I use two submodules for each catalog?

  • Two solutions two submodules, or one submodule and symlink to have your directory structure – Ôrel Sep 25 '20 at 15:52

1 Answers1

1

Yes, you can use git submodules. You just have to see/decide if CatalogA and CatalogB should be in separate repositories.

Since you want these two catalogues to be a submodule, they have to either have separate or one joint git repo.

After that, you only need to add them as a submodule to your projects, like so:

git submodule add https://github.com/<you>/CatalogAandCatalogB

# or if they are in separate repos

git submodule add https://github.com/<you>/CatalogA
git submodule add https://github.com/<you>/CatalogB

Note: if in your project you already have CatalogA and CatalogB, then you can transform your subfolders into submodules easily. This SO answer covers the topic nicely!

mnestorov
  • 4,116
  • 2
  • 14
  • 24