I have four applications (in C language), which communicates by sending C structures via POSIX message queues. All this applications shares two files:
- msg.h file with definition of all structures
- msg.c file with function initializing these structures
I want to keep each application in separated repositories and have one more repository for these shared msg.h and msg.c in fifth repository. What’s more I want to link msg.h and msg.c in each application repository, for example:
In repository SHARED I have msg.h and msg.c. I link these files to repository PROGRAM, so this repository is aware that msg.h and msg.c is maintained by other repository and in case of executing “pull” on PROGRAM repository it will in background pull files from SHARED too.
Is it possible?
Yeah, you can simply use Git Submodules.
Simply keep your shared code in a separate repo and include it as a submodule wherever you need.
Another cool feature of git submodules is that they also store the revision of each submodule. So for instance, in two years from now, you can go back and check which version of SHARED you compiled PROGRAM with today.