git-merge-repo
Merge unrelated repositories into a single one
TLDR
Merge a repository's branch into the current repository's directory
Merge a remote repository's branch into the current repository's directory, not preserving history
SYNOPSIS
git merge-repo [-q] [-p] [-m MSG] [-F FILE] [-t TAG] <target-repo> <source-repo>
PARAMETERS
-q, --quiet
Suppress all output messages.
-p, --patch
Display a diff/patch of changes before merging.
-m MSG, --message MSG
Specify the merge commit message.
-F FILE, --file FILE
Read the merge commit message from FILE.
-t TAG, --tag TAG
Tag the tip of the source repo with TAG after merge.
DESCRIPTION
The git-merge-repo command is a Perl script in Git's contrib directory designed to merge an entire source Git repository into a target repository. It imports all objects, commits, branches, and tags from the source repo into the target, creating a merge commit that combines the histories. This is useful for consolidating projects or absorbing one repo into another while preserving full history.
Unlike standard git merge, which operates on branches within the same repo, git-merge-repo handles cross-repository merges by temporarily cloning the source, fetching its refs into the target's namespace (e.g., refs/source/*), and performing a recursive merge of the default branches (typically master or main). Users can customize the merge message, preview patches, or tag the source commit.
It performs low-level Git plumbing operations like git-read-tree and git-update-ref to avoid conflicts and ensure clean integration. However, it assumes unrelated histories and may require manual resolution for overlapping paths. Best for simple merges; complex cases favor modern alternatives like git subtree.
CAVEATS
Not actively maintained; may conflict with modern Git workflows. Assumes unrelated histories; overlapping paths require manual fixes. Use git subtree or submodules for production. Runs in target repo directory.
EXAMPLE
git merge-repo . ../my-other-repo
Merges ../my-other-repo into current (.) repo.
LOCATION
Found in git/contrib/merge-repo/git-merge-repo; run via full path or symlink.
HISTORY
Developed in Git's early days (circa 2005) as a contrib script by Git contributors to simplify repo consolidation before advanced tools like subtree. Included in Git distributions but rarely updated post-2010.
SEE ALSO
git(1), git-merge(1), git-fetch(1), git-subtree(1), git-read-tree(1)


