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

Re: Pushing and pulling the result of `git replace` and objects/info/alternates

From
Christian Couder <christian.couder@gmail.com>
Date
May 25, 2015, 10:28 UTC
Message-ID
<CAP8UFD20u1OG88bvDAW4vsh=yPihp3TMjc95wDuD=nnr8esBgw@mail.gmail.com>
In-Reply-To
<5562F01D.8000601@gmail.com>
On Mon, May 25, 2015 at 11:49 AM, Stephen Kelly <steveire@gmail.com> wrote:
Show 19 quoted lines
> On 05/24/2015 07:28 AM, Christian Couder wrote:
>> Hi,
>>
>> On Fri, May 22, 2015 at 4:38 PM, Stephen Kelly <steveire@gmail.com> wrote:
>>> I have tried out using `git replace --graft` and
>>> .git/objects/info/alternates to 'refer to' the history in the origin
>>> repo instead of 'duplicating' it. This is similar to how Qt5 repos
>>> refer to Qt 4 history in a different repo.
>>>
>>> Question 1) Is this a reasonable thing to do for this scenario?
>> I think it should work without too much work, but see the answer to
>> the next question.
>
> Ok, thanks. The concern is that there is plenty of documentation for
> git-filter-branch, but no documentation or porcelain for info/alternates
> and little out on the internet about it or git replace and using them
> together.
>
> However, it seems to be a reasonable thing to do.
Yeah.
By the way it looks like I was wrong in my answer to your second question.

You might want to clone using the --reference option to automatically set up .git/objects/info/alternates properly.

(There is an ongoing related thread on the list:
http://thread.gmane.org/gmane.comp.version-control.git/269537)

You might also be able to clone using an option like "--config remote.origin.fetch = 'refs/replace/*:refs/replace/*'" to fetch the replace ref when cloning.

So it looks like you might just need to clone with a few more options than usual.

I haven't tested it so please tell me if it works :-)
Show 17 quoted lines
>>> echo "../../calculator/objects" >
>>> ../.git/modules/compute/objects/info/alternates
>>> git replace --graft HEAD $extraction_sha
>> Maybe use the following instead of the above line:
>>
>> git fetch 'refs/replace/*:refs/replace/*'
>
> Thanks.
>
>>> # And now we see the history from the calculator repo. Great. But, it
>>> required user action after the clone.
>> Yeah, but if the 2 above commands are in a script maybe it's
>> reasonable to ask the user to launch the script once after cloning.
>
> Would it be possible to do this in a hook in the 'integration repo'
> which contains both submodules in the example I posted? Like a fetch
> hook or something?

It is possible to do whatever you want in a hook, but the question is why would you do it in a hook as it looks like it needs to be done only once?

Or maybe I am missing something?

Best, Christian.

Previous: Stephen KellyNext: Stephen Kelly
Message 4 of 6 in “Pushing and pulling the result of `git replace` and objects/info/alternates”
  1. Stephen KellyMay 22, 2015
  2. Christian CouderMay 24, 2015
  3. Stephen KellyMay 25, 2015
  4. Christian CouderMay 25, 2015
  5. Stephen KellyMay 26, 2015
  6. Christian CouderMay 26, 2015

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.