Tuesday 16 July 2019

Merging git repositories - preserving history

Repository A:

File1
File2
File3

Repository B

Filea
DirB

We want to import Repository A into B as a sub directory

First move all the files in Repository A into a subdirectory:

Repository A:

mkdir imported
git add imported
git mv File1 imported/
git mv File2 imported/
git mv File3 imported/
gt commit -m"moved fiels into subdir"
git push

Repository B

git add origin repb
git fetch
git merge --allow-unrelated-histories repb
git push

Hopefully now RepA appears in RepB in directory imported  !