'git pull multiple repositories

I have a question regrading intertwined repositories.

I have a repo, lets call it common_repo.

common_repo holds code which is relevant to most of my other repos, and I wish to pull it whenever I pull other repositories.

We've considered submodules, but as far as I understand this will create numerous copies of the common repo on my machine. This is undesireable as I may have differnet versions on my computer of the same files according to when I last pulled the dependent repo, which could lead to confusion.

Another alternative would be using some custom scripts such as sggested here. However this is not cross paltform (we have multiple developers working on different OS's), requires deployment on each machine, and doesn't play well git GUI clients such as smartgit or source tree.

Is there a better solution which we haven't considered?



Solution 1:[1]

You can update all git repositories in a directory with a bash command, as you mentioned

find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull

Credit: https://medium.com/@codenameyau/updating-multiple-repos-with-one-command-9768c8cdfe46

Another option I can propose to you would be to explore the post-merge git hook, where you could accomplish something similar to the above on git pull. Any language, compiled or interpreted can be used in a git hook as long as the appropriate interpreter is available on the system. This may be a good resource: https://git-scm.com/docs/githooks

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1