Git Repositories: How to Structure for a Library and Multiple Small Programs

gitversion control

I have some code that uses a library that I and others frequently modify (usually only by adding functions and methods). We each keep a local fork of the library for our own use.

I also have a lot of small "driver" programs (~100 lines) that use the library and are used exclusively by me. Currently, I have both the driver programs and the library in the same repository, because I frequently make changes to both that are logically connected (adding a function to the library and then calling it).

I'd like to merge my fork of the library with my co-workers' forks, but I don't want the driver programs to be part of the merged library.

What's the best way to organize the git repositories for a large, shared library that needs to be merged frequently and a number of small programs that have changes that are connected to changes in the library?

Best Answer

Sounds like a good fit for git submodules - move the library into it's own, public repository, then add it as a git submodule to the repository where you keep your driver programs. If you haven't used git submodules, it might take some getting used to; understanding how it works requires some knowledge of git's internals. Here's a tutorial that I found useful.

Related Topic