git-glue is a PHP CLI app to merge the contents of a list of source repositories into subdirectories within a target repository while preserving the git history of each source.
The approach in inspired by the blog post "Moving Files from one Git Repository to Another, Preserving History" by Greg Bayer except for the fact that we want all the content from each source added to the target so there is no need to use filter-branch.
- Go to the latest release
- Download the
git-glue.phar
file - Run
phar git-glue.phar
to see a list of available commands - Create a
config.php
from where you intend to run git-glue. See the sample file for configuration options. The location can either be a git checkout of the target repository on an arbitrary directory if theworkingDir
configuration option is defined.
- Run
php git-glue.phar glue
. - Wait - the process can take a while
- Go to the working directory, examine the result and decide what to do next (merge the git-glue working branch, push it etc.)
git-glue can help apply patches to source directories even after they have been merged.
This can be useful when dealing with changes that have been left behind. For example a pull request can be converted to a patch file by adding .patch
to the URL.
git-glue uses the source repository list to determine where in the target repository the patch belongs and tries to apply the patch accordingly.
- Run
php git-glue.phar apply-patch [path to patch]
- Go to the working directory, examine the result and decide what to do next (merge the git-glue working branch, push it etc.)
Development of git-glue has been sponsored by Danskernes Digitale Bibliotek.