Daniel Pietzsch

Personal blog. Mostly photos.

Merging two Git repos

Today I learned, you can indeed merge two Git repositories and keep the history intact. Not quite sure, if I will need this ever again, but it’s good to know I could. Here’s the code snippet of Andresch Serj’s answer on Stack Overflow:

If you want to merge project-a into project-b:

cd path/to/project-b
git remote add project-a path/to/project-a
git fetch project-a --tags
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge
git remote remove project-a