How to merge several Git repos into one and interleave histories

后端 未结 2 552
醉话见心
醉话见心 2021-01-11 22:44

My situation is that I have two Git repositories that I need to merge into a single repository (there are actually more repos, but I can start with two).

The two rep

2条回答
  •  执念已碎
    2021-01-11 23:25

    The solution turned out to be much more involved than I had hoped for. It involves manipulating and combining the output of two (or more) git fast-export streams, and importing them into a new repository using git fast-import.

    In short, a new fast-import stream is generated by traversing two input streams, and switching back-and-forth between them based on a date-sorted log from the main branches.

    I have implemented the solution in a Python script called join-git-repos.py, that I put in a GitHub repository here.

提交回复
热议问题