I'm creating a monorepo that will include 2 current separate repositories. Let's just call then repo1
& repo2
However, I'm not 100% sure how to preserve the git histories of both correctly.
Both will have some similar branch names that I'm worried might have some impact in merging both successfully without conflicts? If I can only get the git history for a single branch on each repo, it's not the end of the world.
Both of the git repositories are still in progress, so, I am also not sure on how to merge in any future changes after I have already merged the current state of each repo into the monorepo (I'm not too worried about if it will be bit of a headache, but if it is a relatively simple solution then I'm all ears!)
I am aiming to have the following folder structure
monorepo
┣ packages
┃ ┣ repo1
┃ ┣ repo2
┗ package.json
I've done a little research and found I could do the following...
git remote add repo1 *git URL of repo1*
git fetch repo1
git merge repo1/main --allow-unrelated-histories
However this has 2 issues
- It merges into the root of the folder, so there is a
package.json
conflict, and I want to merge it into thepackages/repo1
directory. - It's only for a specific branch
- Preferably it would be the entire git history, but again, I could live with this if getting the entire git history is a lot more complicated.