Skip to content

Instantly share code, notes, and snippets.

@jhrr
Created May 20, 2019 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhrr/f0510f490efad1f601da4f5ebdfe58cc to your computer and use it in GitHub Desktop.
Save jhrr/f0510f490efad1f601da4f5ebdfe58cc to your computer and use it in GitHub Desktop.
Methods to merge two git repos into one.
# Brings over all tags/branches keeping history intact for the
# incoming remote data.
$ cd path/to/source-repo
$ git remote add target path/to/target
$ git fetch target --tags
$ git merge --allow-unrelated-histories target/some-branch
$ git remote remove target
# Or, to merge just the one branch this works but it loses all
# the extra history that the above method preserves.
$ cd path/to/source-repo
$ git remote add target path/to/target
$ git fetch target some-branch:some-branch. # Incoming name should be unique between repos I suspect.
$ git merge --allow-unrelated-histories some-branch
$ git remote remove target
$ git branch -D some-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment