Query on how to use version control on files which are common to many projects

Hi All,

Please can someone advise on what to do in the following instance, please go easy as I’m very new to GitLab:

I have multiple projects with many code files.
Some projects have files which are shared amongst multiple projects.
Rather than creating a copy of these files in every GITLab project and updating them individually, is there not a way to create shared files or folders within GitLab. Any suggestions on how to tackle this issue are welcome.

Thanks for reading.

Regards,
Mo

Hi Mo! Welcome, and thanks for posting.

There’s a discussion along these lines here in stack overflow - albeit from 2015-2017 which is a very long time ago for GitLab!

The final post suggests Git submodules but also goes on to suggest that dependencies between packages would be a better approach.

You’d be able to use the package repositories once they’ve moved to core (I’m assuming you don’t have a license that provides them already) given various assumptions, such as the language you’re coding in and whether we support it.

It looks like this will be completed in 13.3.

Do either of these approaches look useful?

Ben

2 Likes

PS. More on submodules in the git documentation.

And I dug around, as it was bugging me. A submodule can be qualified with a branch name though nothing else (a tag or a SHA for example) which would seem to be necessary to tackle the inevitable subset of your projects that need a different version of the shared files :wink:

2 Likes

@bprescott: I’m quite sure that a git submodule within a repository is associated with a specific commit SHA.

Hi All,
Sorry about the delay.
I will give the submodule a try, when I’m next working on the project and get back to you.
Regards,
Mo