0

We have multiple Git repositories (one per project..), and we have configuration files which should stay "synced" across all projects, but should also be in the Git repository, for example - pipelines yaml, and static analysis configuration yaml.

What is the best way to hold those configuration files in a central place? (e.g. central Git repository, symbolic links to remote host?)

Maybe using Bitbucket webhooks with our own custom "agent" is the best option?

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
Rotem
  • 432
  • 1
  • 5
  • 23
  • Submodules are the answer. The question is: do you want a monolith repo which tracks the config files with all the projects as submodules, or a separate config repo that gets pulled in as a submodule in each project? – Pockets Feb 13 '17 at 09:57
  • http://stackoverflow.com/a/9733277/2303202 maybe you could find some solution with use of include – max630 Feb 14 '17 at 19:20
  • @pockets - sub modules adds a directory to the tree, which is a problem for us. – Rotem Mar 26 '17 at 17:40
  • @max630 - this seems to be used only to include gitconfig files.. – Rotem Mar 26 '17 at 17:40
  • As I said in my comment, you have two options with submodules, and I don't see why the former doesn't work. – Pockets Mar 27 '17 at 18:24

1 Answers1

1

Put all your config file in a Git repository, and reference that repository as a submodule from the other Git repositories.

Notice that whenever you change the shared repository (containing common config files), you have to sync regularly from each of the other Git repositories, e.g.:

>git submodule update --remote

would pull all latest changes from all the submodules of the repository you launch this command within.

Luca Cappa
  • 1,687
  • 1
  • 9
  • 19
  • Git submodule requires that I'll add a directory, and the config files should be in the root directory. Am I wrong? And one more thing is that I won't be able to "push" updates to all Git repos from a central place (not sure if there's a way to do so) – Rotem Feb 13 '17 at 12:32
  • You could create a submodule in any subdirectory, i.e. `>git submodule add ssh://user@host/bla/bla subdir/sub1` There is no way to to push updates to repositories, each of them needs to be updated. – Luca Cappa Feb 13 '17 at 16:19
  • Cappas's - I don't want another directory in my root dorectory. Thats a problem and git submodules are only available within directories – Rotem Mar 26 '17 at 17:42