First, make the legacy repo a remote of your repo. It can be referenced by a URL or by a file path.
git remote add legacy <path or URL to legacy>
Fetch it.
git fetch legacy
A [legacy/master]
|
B F [master]
| |
C G
| |
D H
|
E
At this point we could smack them together with git merge --allow-unrelated-histories
but that increases the chance of a bad merge. Instead, first stitch the histories together by rewriting the commits in your new repo onto the commit where they diverged. Let’s say that was commit D.
git rebase D
[legacy/master] A
| F1 [master]
B |
| G1
C /
|/
D
|
E
Note that the first commit in the new repo should have the same content as D and will probably disappear. If it remains, it should only contain the differences introduced by the copy. These may be significant.
Now merge normally.
git merge legacy/master
M [master]
/|
/ |
[legacy/master] A |
| F1
B |
| G1
C /
|/
D
|
E
And make this the central repo going forward.
CLICK HERE to find out more related problems solutions.