Subtree merging is another alternative.
For the gory details behind the git-subtree
script see this and this (in the order of increasing hardcore-ness).
To cite the latter manual:
There are situations where you want to include contents in your project from an independently developed project. You can just pull from the other project as long as there are no conflicting paths.
The problematic case is when there are conflicting files. Potential candidates are Makefiles and other standard filenames. You could merge these files but probably you do not want to. A better solution for this problem can be to merge the project as its own subdirectory. This is not supported by the recursive merge strategy, so just pulling won’t work.
What you want is the subtree merge strategy, which helps you in such a situation.
The git-subtree
script (which is included with Git in its contrib
section in its relatively modern versions) facilitates subtree merges.