Reputation: 23
We currently have an environment in which multiple repositories contain the same files, which we are trying to 'export' so that updates to the files don't force us to update every single repository.
The following is an abstract layout of our desired setup, we basically have a folder 'share' that provides a package that should be included in the other projects on remote.
local:
+---1
| 1.txt
+---2
| 2.txt
+---3
| 3.txt
\---share
\---somepackage
somefile.txt
remote:
+---1
| | 1.txt
| \---somepackage
| somefile.txt
+---2
| | 2.txt
| \---somepackage
| somefile.txt
\---3
| 3.txt
\---somepackage
somefile.txt
When pushed to remote, the shared files should be contained within each repository. Changes to the share-folder should be applied to each shared repository (best case immediately, worst case when pushed to remote).
We use windows as our development environment, but the pushed repositories will be used by a linux system that runs each repository, if that is relevant.
We have thought about using symlinks, but according to this SO post hard links are not managed by git and soft links would not have the functionality that we desire. The post is quite old and applies to linux development environments, so I am curious whether there have been changes regarding this and if it could be applied to windows.
As far as I am aware, the best solution would be to create a script like "post-merge" (mentiond in the same SO post) that pulls files from outside the repo into the repo and then pushes into the remote repo. That would make it a "pre-push" hook if I had to give it a name.
I am currently working alone on this problem and am not very savvy with git, but surely there are other far more elegant solutions to solve this problem.
Upvotes: 2
Views: 703
Reputation: 1327364
The normal solution involves git submodule
combined with the command git submodule update --remote
executed in each repository 1, 2, 3
That way:
shared
repository to its upstream repositorygit submodule update --remote
in each repositories 1, 2, 3, then add, commit, and push.shared
subfolder (assuming share includes multiple packages, not just somepackage
).If you need 1/somepackage
instead of 1/shared/somepackage
, you would need to add symlinks to your 1, 2, 3 repositories (since symlinks are properly managed)
Upvotes: 3