0

We currently have a repository named my-company-php-library where we have business-specific tools that are reused across a couple of other projects.

Lately, we've added other general purpose helper stuff like array helpers, cache abstractions, Slack notification abstractions, etc.

We're considering splitting the monolith library, but having a dozen small repositories seems excessive:

  • my-company/array-helper
  • my-company/cache
  • my-company/notifications
  • my-company/session-handler
  • my-company/db

Question

Is there a way in git where the entire library is in the same repository, but you can clone only a portion of it?

When we have a one-off project that just needs the notifications module, it seems too much to import the whole thing. Yet, having an entire repository with 2 files also seems like an overkill.

rodrigo-silveira
  • 12,607
  • 11
  • 69
  • 123

1 Answers1

1

You can keep everything in the one repository and for:

Is there a way in git where the entire library is in the same repository, but you can clone only a portion of it?

Git sparse checkout is what helps - take a look at this answer.

Additionally git virtual file system, a git extension by Microsoft may also be something to take a look at.

In general depends on the size of the repo and how people want to use it. One one hand you maybe have more commits that are "independent" on one another, on the other hand you have more repos to deal with, for example if one bug requires fixing source that's in multiple repos... Sometimes it's not what's better, but what's less bad.

cantSleepNow
  • 9,691
  • 5
  • 31
  • 42