So I did what any normal person does, I googled it. Turned out this is easier to do that I thought it would be - the results are easy to find on google - but I thought I'd share my use case - not only might it help someone else - But it will help me when I want to do this again - I willn't have to search, I can just look at my blog :-)
This posting on stackoverflow asks the question perfect:
https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories
Question:
"Consider the following scenario:The Best Answer:
I have developed a small experimental project A in its own Git repo. It has now matured, and I'd like A to be part of larger project B, which has its own big repository. I'd now like to add A as a subdirectory of B.
How do I merge A into B, without losing history on any side?"
If you want to mergeThis also worked pretty well in my case, I ran into one conflict - so off to google again to find how to resolve that (again, GIT makes it pretty easy to deal with the conflict)project-a
intoproject-b
:This method worked pretty well for me, it's shorter and in my opinion a lot cleaner.cd path/to/project-b git remote add project
git remote add project-a path/to/project-a git fetch project
git fetch project-a git merge
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge
git remote remove project-a
Note: The--allow-unrelated-histories
parameter only exists since git >= 2.9. See Git - git merge Documentation / --allow-unrelated-histories
https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/
This needs to be read - but the basics of it the arrows in the file show where the conflict is, and from which branch the conflict came from. And the equals is the dividing point.
So you might see something like
If you have questions, please
<<<<<<< HEAD
open an issue
=======
ask your question in IRC.
>>>>>>> branch-a
Decide if you want to keep only your branch's changes, keep only the other branch's changes, or make a brand new change, which may incorporate changes from both branches. Delete the conflict markers
<<<<<<<
, =======
, >>>>>>>
and make the changes you want in the final merge. In this example, both changes are incorporated into the final merge:If you have questions, please open an issue or ask in our IRC channel if it's more urgent.
Add or stage your changes: git add *and commit the changes with a comment:
git commit -m "resolved merge conflict"
There are other cases covered by the github help competing changes to a file that deal with complete file conflicts