0

Two repos of the same project with different histories (unrelated from the git point of view). I need to merge them into one repo and remember histories of both.

The main problem is that the one of the repos one additional directory.

 repo1  ---DIR----[project dirs]


 repo2  ---[project dirs]

The project dirs are almost the same.

I have tried to move the directories, create dummy branches, then merge unrelated histories and then merge. But it never see the conflicts - it just replaces files using one of the repos.

Is it possible to merge two separate repos?

0___________
  • 60,014
  • 4
  • 34
  • 74
  • Just add `repo2` as a remote to `repo1`, try to pull from the newly added remote it and resolve the possible conflicts(Don't forget to commit after resolving the conflicts)? After that, you can push to the common repository. – dan1st Feb 03 '20 at 16:19
  • @dan1st but then I have `DIR` and `[project dirs]` at the same level and another `[project dirs]` in the DIR directory. I want to merge `[project dirs]` – 0___________ Feb 03 '20 at 16:28
  • Try [`git subtree`](https://stackoverflow.com/a/14992078/7976758). Backup `repo1` and run in it `git subtree add --prefix=DIR repo2 master` – phd Feb 03 '20 at 16:38
  • @phd `fatal: refusing to merge unrelated histories` – 0___________ Feb 03 '20 at 17:13
  • PS and there is no `--allow-unrelated-histories` – 0___________ Feb 03 '20 at 17:20

0 Answers0