Subject: Git: Having trouble merging two repositories by interweaving their histories

From: THILLOSEN Andreas <[email-masked]>
Date: Mon, 09 Sep 2013 23:26:42 +0200

Hi,

I recently stumbled over problems, while trying to merge two
repositories (RepA and RepB) into a single one (RepM).
I must mention that indexed files in RepA are totally distinct from
indexed files in RepB, thus no conflict shall appear.
The problem is that I never manage to get the exact result I'm hoping for:

1] RepM should have the entire commit histories of both RepA and RepB.
2] In RepM, indexed files should be separated in two directories:  DirA
(for files associated to RepA), and DirB (for files associated to RepB).
3] I should be able to bissect easily within the history of RepM, even
for old commits. It implies that if I checkout a particular commit
(initially associated to RepA), indexed files initially associated to
RepA and RepB should get updated (and not only files associed to RepA).
It implies "interweaving" their histories, so that I can get a "state"
of both RepA and RepB around a same time period of time.

For my scenario, I used these kinds of commands (from a git bash
launched within an initialized repository RepM):

git remote add RepA /path/RepA
git fetch RepA
git checkout -b RepA/master
git merge -s recursive -Xsubtree=DirA RepA/master

git remote add RepB /path/RepB
git fetch RepB
git checkout -b RepB/master
git merge -s recursive -Xsubtree=DirB RepB/master

With these commands, only my first point 1] is satisfied (I can see the
full history associated to RepA and RepB).

If I checkout RepM to an old commit, the files indexed by RepA or RepB
are updated by ignoring the directories DirA and DirB (point 2] is not
satisfied).

Moreover, only files associated to either RepA or RepB (depending on the
origin of the commit) get updated (point 3] is not satisfied).
In history, commits from RepA are all appearing at the beginning, and
commits from RepB are appearing at the end (they are clearly being
separated).
Should "rebase" help me to solve this? With what kind of parameters?

Greetings,

Andreas THILLOSEN.