TEN Design
TEN Design

Reputation: 717

Git & Subdirectories / Submodules?

I'm relatively new to git. However, I want to be able to start deploying my sites via bitbucket/netlify so I have question for the git pros out there!

The CMS I use publishes all my sites as static html/css/js files into a directory structure like this...

app
→sites
→→customer 1
→→customer 2
→→customer 3

What would be recommended for this, a repo for each customer? I am unfamiliar with how submodules work, is maybe this a better solution?

Upvotes: 1

Views: 95

Answers (1)

Ajk_P
Ajk_P

Reputation: 1874

From the Git Submodule Doc

Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.

So in a way, submodules are built to share dependencies/libraries/components,etc between repositories.

Consider you have 2 projects:

  • A has a dependency on C
  • B has a dependency on C

Then C would be a great choice for a submodule.

In your case, your specific customer projects don't seem to be going to be shared between sites so they aren't a good choice for submodules.

On the other hand, if the CMS had a better structure, it would have a tree like this:

→→customer 1
→→→AppDependency
→→customer 2
→→→AppDependency
→→customer 3
→→→AppDependency

You could have 3 different repositories (1 for each customer) and AppDependency would be a good choice for a submodule. I would strongly suggest, trying to go towards a structure like this, as this could prove to be very beneficial to your projects long-term.

In your current structure, I would say (unfortunately), there is no way to separate concerns between the sites. (If you update the shared code, all are going to be affected), so in that case, I would suggest just having a single repo and just being extra careful with updating the common code.

Upvotes: 2

Related Questions