'Strategy for maintaining shared code between projects?

I have about 5 or 6 projects that use "toolkit" code I've written. The problem I've came across is doing updates to toolkit code; when I do an update I usually need to apply these updates manually to the other projects.

Is there a common strategy for handling this kind of issue?



Solution 1:[1]

You can use git submodules.

Create a repository for your "toolkit" code and use it as a submodule for each of the other projects. To add a submodule, you can do:

$ git submodule add url_to_repository path_to_local_submodule

When cloning repositories with submodules, there are another steps required:

$ git submodule init and

$ git submoudule update

It will fetch the repositories that are submodules and checkout the appropriate commit of each.

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