git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Kerry, Richard" <richard.kerry@atos.net>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: RE: Can I Insert some Ancient History into a repo?
Date: Fri, 12 Mar 2021 15:37:59 +0000	[thread overview]
Message-ID: <AM0PR02MB4081BAED92DBEC1F3E33B2059C6F9@AM0PR02MB4081.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <87o8jcus0m.fsf@evledraar.gmail.com>

I've got back onto this issue after a couple of months on other matters,

From: Ævar Arnfjörð Bjarmason <avarab@gmail.com> 
Sent: 02 December 2020 15:50

>On Wed, Dec 02 2020, Kerry, Richard wrote:
>
>> 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).
>
>I've brought in existing repos into other repos like what you describe you shouldn't be doing, "git merge --allow-unrelated-histories" exists for a reason, you can >just use it.

I don't think I'm saying I shouldn't be doing it, just that doing it and leaving it as disjoint history doesn't seem like what I'm looking for for future clarity of history and for some work I need to do quite soon.
And I have discovered --allow-unrelated-histories, so I knew that was possible.

>I do think you're starting from the wrong starting point though, maybe not in your thinking, but your post just says you want to combine these, and how to do it.
>
>The reason I've done this in the past is for some practical reason. E.g. you might want to arrange it so a "git blame" or "git log"
>on a file traverses down the right path & history, or to be able to refer to commits by SHA1.

As you say, I should be doing it for a clearer reason, which I should have been clearer about when I first asked.  My reasons do include the reasons you give, so blame and log should than work, but more significant is that I want to merge some of the work done on the L2 branch into the L1 main line of development.

>Depending on what you actually want to with the end result merging or using grafts might not be the best thing to do. E.g. a perfectly OK thing in some cases is >to just have a side-repo somewhere to keep the old history, you can add it as a remote to do some ad-hoc inspection, but never need to push a merger of the >two to the current active repo.


From: Johannes Schindelin <Johannes.Schindelin@gmx.de> 
Sent: 02 December 2020 11:15

>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.

I don't think this would work for me as you say it is local-only so it won't get pushed to my remotes, which wouldn't be satisfactory.
Though I have to admit I don't really understand what it would be doing to git's structures, so maybe it would be useful.


Giving it some thought during the intervening time it seemed that to do this much reorganization of existing data I'd have to start from scratch and rebuild a repo importing the various exports, in whole or in part, in the right order and with right references edited in.  I've split the L1 export at the point where the L2 branch starts and generated master up to that point, then imported L2 so master is now A-B-C-D-J-K-L-M, as required.
Then I've taken the remainder of the L1 export and edited the export to set the base revision and the branch and imported the result, so L1 is now A-B-C-D-E-F-G-H.  That gives me a structure exactly as I want, with master being the same as the original L2 but with the appropriate additional ancient history, and L1 being as required.

However, I'm now not able to write the results back to BitBucket.  I've used "remote add" to add the reference to the existing remote repo where L2 came from.  But when I try "git push origin" it tells me :

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
    git push --set-upstream origin master

Why does it do that?
If I'm setting up a more conventional local repo to push to a remote it is usually sufficient to do "git remote add origin" and it'll then push (ie one set-up using a simple fast-import from cvs2git, with the instance on the remote server created there).
Presumably my current position of generating the local repo from scratch from multiple imports means it's missing something vital.  What might it be missing?  Is it just that it is aware that it did not originate from a fetch and the above set-upstream is the best way to fix it?  But other repos that originate from CVS exports are happy with just "remote add".
Does git know that the repo of the same name on the remote server is somehow "different" from my hand-crafted repo?


Regards,
Richard.

  reply	other threads:[~2021-03-12 15:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 10:54 Can I Insert some Ancient History into a repo? Kerry, Richard
2020-12-02 11:15 ` Johannes Schindelin
2020-12-02 15:50 ` Ævar Arnfjörð Bjarmason
2021-03-12 15:37   ` Kerry, Richard [this message]
2021-03-13  9:59     ` Kerry, Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM0PR02MB4081BAED92DBEC1F3E33B2059C6F9@AM0PR02MB4081.eurprd02.prod.outlook.com \
    --to=richard.kerry@atos.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).