I will not give advice on “How you should go about this”. But I’ll explain how to accomplish integrating a third repository with common code into the other repositories: This is a job for git submodules. git submodules allow you to reference a snapshot of a git repository at a specified path:
git submodule add git://example.com/repository.git path
Afterwards create a commit. Now a snapshot of the given repository is referenced at path
.
Populating the submodule
- Execute
git submodule init
- Execute
git submodule update
Every configured submodule will be updated to match the state it is supposed to look like.
Updating a submodule to a later commit
- Change into the directory of the submodule
- Perform a
git pull
/git fetch
+git checkout
to update the submodule to the desired commit / tag - Create a new commit to update the commit in the
.gitmodules
file
Take a look at the official manual for further information on submodules.