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

Re: Merging (joining/stiching/rewriting) history of "unrelated" git repositories

From
Jakub Narebski <jnareb@gmail.com>
Date
May 20, 2019, 13:54 UTC
Message-ID
<86a7fhp6yv.fsf@gmail.com>
In-Reply-To
<CABPp-BGycoHEMN27Z9rAccT5yVRf3N50o4sc3wo8uE_HLR9QbA@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 51 quoted lines
> On Wed, May 15, 2019 at 8:30 AM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> On Wed, May 15 2019, Piotr Krukowiecki wrote:
>>>
>>> I'm migrating two repositories from svn. I already did svn->git
>>> migration (git-svn clone) and now have two git repositories.
>>>
>>> I would like to merge them into 1 git repository, but to merge also
>>> history - branches and tags.
>>>
>>> The reason is that the svn repositories in fact represent one
>>> "project" - you had to download both of then, they are not useful
>>> separately. Tags were applied to both repositories, also list of
>>> branches is almost identical for both.
>>>
>>> So right now I have:
>>>
>>>     - projectA:
>>>        master: r1, r4, r5, r7
>>>        branch1: r10, r11, r13
>>>     - projectB:
>>>        master: r2, r3, r6
>>>        branch1: r12, r14
>>>
>>> The content of projectA and projectB is different (let's say projectA
>>> is in subfolder A and projectB is in subfolder B). So revisions on
>>> projectA branches have only A folder, and revisions on projectB
>>> branches have only B folder.
>>>
>>> But I would like to have:
>>>
>>>     - projectAB:
>>>        master: r1', r2', r3', r4', r5', r6', r7'
>>>        branch1: r10', r11', r12', r13', r14'
>>>
>>> Where all revisions have content from both projects. For example, the
>>> r5' should have the "A" folder content the same as r5, but also should
>>> have "B" folder content the same as in r3 (because r3 was the last
>>> commit to projectB (date-wise) before commit r5 to projectA).
>>>
>>> There's additional difficulty of handling merges...
>>>
>>>>
>>> Any suggestions on what's the best way to do it?
>>>
>>>
>>> Currently I'm testing join-git-repos.py script
>>> (https://github.com/mbitsnbites/git-tools/blob/master/join-git-repos.py)
>>> but it's slow, memory inefficient and handles "master" branch only...
>>
>> You might be able to use https://github.com/newren/git-filter-repo
[...]
Show 6 quoted lines
> Somewhat interestingly, a search on others having tried to solve this
> same problem turned up
> https://github.com/j5int/jbosstools-gitmigration, which apparently is
> based on git_fast_filter, which is the predecessor of filter-repo.
> Perhaps that tool would be useful to you as-is, though they apparently
> do ignore merges.

There is also reposurgeon tool; though its main purported purpose is to aid migrating from one version control system to another, it can also be used to edit repositories (utilizing fast-import stream).

  https://gitlab.com/esr/reposurgeon
  http://www.catb.org/~esr/reposurgeon/

Hope that helps, -- Jakub Narębski

Previous: Piotr KrukowieckiNext: Piotr Krukowiecki
Message 6 of 8 in “Merging (joining/stiching/rewriting) history of "unrelated" git repositories”
  1. Piotr KrukowieckiMay 15, 2019
  2. Ævar Arnfjörð BjarmasonMay 15, 2019
  3. Elijah NewrenMay 15, 2019
  4. Piotr KrukowieckiMay 16, 2019
  5. Piotr KrukowieckiMay 17, 2019
  6. Jakub NarebskiMay 20, 2019
  7. Piotr KrukowieckiMay 21, 2019
  8. Piotr KrukowieckiMay 16, 2019

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.