git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Git: Having trouble merging two repositories by interweaving their histories

From
TATHILLOSEN Andreas <thillosen@free.fr>
Date
Sep 9, 2013, 21:26 UTC
Message-ID
<522E3D12.4090004@free.fr>
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.
Next: Andreas Schwab
Message 1 of 3 in “Git: Having trouble merging two repositories by interweaving their histories”
  1. THILLOSEN AndreasSep 9, 2013
  2. Andreas SchwabSep 9, 2013
  3. THILLOSEN AndreasSep 10, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.