How can I join two Git repositories by interleaving their commit history according to commit / author date?
We can assume both repositories contain separate files. However, folder names might be identical and should be deep merged.
For example, repository a
looks like:
a1.txt
src/a2.txt
A1---A2---A3 <--- a/main
While repository b
looks like:
b1.txt
src/b2.txt
B1---B2---B3 <--- b/main
Assuming the commit / author date order is A1
, B1
, B2
, A2
, A3
, B3
, the resulting repository c
should look like:
a1.txt
b1.txt
src/a2.txt
src/b2.txt
A1---B1---B2---A2---A3---B3 <--- c/main
We can also assume that no two commit / author dates will be identical such that the order is well defined.
This is unlike Merge two Git repositories without breaking file history which keeps two branches and creates a merge commit.
This may be a simpler case of How to merge several Git repos into one and interleave histories