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

Re: Can I Insert some Ancient History into a repo?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 2, 2020, 11:15 UTC
Message-ID
<nycvar.QRO.7.76.6.2012021210390.25979@tvgsbejvaqbjf.bet>
In-Reply-To
<AM0PR02MB40811C5C2E8B13B63D06E4B49CF30@AM0PR02MB4081.eurprd02.prod.outlook.com>
Hi Richard,
On Wed, 2 Dec 2020, Kerry, Richard wrote:
Show 60 quoted lines
> The Story
> - - - - - - - -
> My project, "L", has two branches "L1" and "L2".  It was developed as L1
> for a long period, then a branch, L2, was made and further development
> done on that.  Since the branch there has been further development on
> L1.
>  
> A-B-C-D-E-F-G-H
>              \
>               J-K-L-M
>  
> (That's supposed to show J branching off D.  I'm writing this with
> proportional spacing so it may look different on receipt)
>
>
> The Reality
> - - - - - - - - -
> L was developed in CVS as its trunk.  That is what I am now referring to as L1.
> A-B-C-D-E-F-G-H
>  
> At some point a snapshot was taken and put into Subversion.  That is what I am now referring to as L2.
> It is either
> D-J-K-L-M
> Or, more likely, just
> J-K-L-M
> (If some work was done on the snapshot before it was used to start the
> new project in SVN, which I think it was)
>  
> L2 has been converted to git using git's built-in Subversion handling.
> I have a backup of the CVS repository for L1 and I can easily convert it
> to git using cvs2git.
>  
> What I would like to do is to merge these two branches into a single git
> repo.  Specifically, to insert L1 into the existing git repo which is
> currently only L2.
>
> (The subversion server no longer exists, and I don't have easy access to
> the repository backup, and there may have been work done since the
> import.  I have a full backup of the CVS repository and I can easily
> convert it to git using cvs2git, with any extra parameters required.)
>
> I've read up on merging repositories and I can easily get L1 into the
> same repo as L2, as a separate line of development.  However, merging it
> is not the right thing to do, as that leaves me with L1 and L2 having
> separate starting points, with a merge leading to there being only one
> head.  That's the opposite of what I want - I want to keep one starting
> point (that of L1), and branch L2 off it (with L2 ending up as master).
>
> cvs2git works by generating fast-import scripts, so I can intercept the
> result of that and edit the import scripts if necessary.  I can even
> dump L2 and rebuild everything using fast-import if that's the best
> option.  Maybe L2 needs to be imported into L1 after generating a tag in
> L1 to indicate where the branch happens?  That seems to be a more
> complex work-flow for this task - I would hope to be able to do minor
> manipulations of branches and only one fast-import (ie L1).
>
>
> So, I'm still looking to see if I can find any other way of wrangling
> branches to make this happen, but I'd appreciate anyone else's advice on
> how to achieve my merger.

If I were you, I would use `git replace` to pretend that the `D` in your `L2` history has the `C` in your `L1` history as parent:

	git replace --graft <D-as-in-L2> <C>

Note that this is a local-only operation. Even if you push, the remote repository won't know that you grafted L2 onto L1 in your local worktree.

Ciao, Johannes

Previous: Kerry, RichardNext: Ævar Arnfjörð Bjarmason
Message 2 of 5 in “Can I Insert some Ancient History into a repo?”
  1. Kerry, RichardDec 2, 2020
  2. Johannes SchindelinDec 2, 2020
  3. Ævar Arnfjörð BjarmasonDec 2, 2020
  4. Kerry, RichardMar 12, 2021
  5. Kerry, RichardMar 13, 2021

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.