Merge two Git repositories without breaking file history

I need to merge two Git repositories into a brand new, third repository. I’ve found many descriptions of how to do this using a subtree merge (for example Jakub Narębski’s answer on How do you merge two Git repositories?) and following those instructions mostly works, except that when I commit the subtree merge all of the files from the old repositories are recorded as new added files. I can see the commit history from the old repositories when I do git log, but if I do git log <file> it shows only one commit for that file – the subtree merge. Judging from the comments on the above answer, I’m not alone in seeing this problem but I’ve found no published solutions for it.

Is there any way do merge repositories and leave individual file history intact?

9 Answers
9

Leave a Comment