All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Tennant <sdt@sebyte.me>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: How to mirror and augment a git repository
Date: Sun, 12 Mar 2023 18:11:22 +0000	[thread overview]
Message-ID: <87pm9d6drp.fsf@sebyte.me> (raw)
In-Reply-To: ZAyWUS27M+degQxj@coredump.intra.peff.net

Quoth Jeff King <peff@peff.net>
on Sat, 11 Mar 2023 09:55:13 -0500:
> On Sat, Mar 11, 2023 at 10:47:40AM +0000, Sebastian Tennant wrote:
>
>> Here are the actions I'm taking to configure the mirror:
>>
>>  $ git clone --bare https://url.of/project.git
>>  $ cd project.git
>>  $ git remote rename origin upstream
>>  $ git config remote.upstream.fetch\
>>        '+refs/heads/*:refs/remotes/upstream/*'
>>  $ git fetch upstream --prune
>>
>> At this point there are no refs under refs/heads (and very many under
>> refs/remotes/upstream).
>
> You'd have refs under refs/heads at this point.  They were created
> when you did the original bare clone (since bare clones fetch all
> heads to start with, though they don't set up a refspec).

I see the refs under refs/heads at last!

My mistake was looking for them in the file system (instead of in file
‘packed-refs’).

> And they won't be deleted by the pruning fetch, of course, because
> you configured the refspec to limit itself to refs/remotes/upstream
> on the local side.
>
> If you don't want them (and I think you don't), you can just initialize
> the repository directly, and then fetch, like:
>
>   git init --bare project.git
>   cd project.git
>   git config remote.upstream.url https://url.of/project.git
>   [and then configure refspec and fetch --prune as before]

This is precisely the behaviour I've been wanting (and mistakenly
expecting).

>> Here are the actions I'm then taking on a client:
>>
>>  $ git clone --bare mirror:path/to/project.git
>>  $ cd project.git
>>  $ git remote rename origin mirror
>>  $ git config remote.mirror.fetch\
>>        '+refs/heads/*:refs/remotes/mirror/*'
>
> This bare clone will do the same thing. So you'll end up with a copy
> of all of the heads created in the earlier step. Worse, they won't
> be the current state of those branches, but stale ones left from
> when you created the mirror repo.
>
> I think you want _two_ refspecs in the clients:
>
>   - one to fetch the client-local branches stored on the mirror. That
>     is:
>
>       +refs/heads/*:refs/remotes/origin/*
>
>     and those branches just appear as normal.
>
>   - one to fetch the mirrored upstream branches from the special
>     namespace on the mirror. That one is:
>
>       +refs/remotes/upstream/*:refs/remotes/upstream/*

Yup, this is what I want, and actually what I already have in place,
configuration wise.

The problem was in my partial understanding of the consequences of
passing option --bare to ‘git clone’ (and in my not thinking to look
in file ‘packed-refs’).

Thanks again Jeff.

Sebastian

  reply	other threads:[~2023-03-12 18:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-04 12:19 How to mirror and augment a git repository Sebastian Tennant
2023-03-05  9:02 ` Bagas Sanjaya
2023-03-05  9:50   ` Sebastian Tennant
2023-03-06  8:08 ` Jeff King
2023-03-08 16:54   ` Sebastian Tennant
2023-03-09  3:12     ` Jeff King
2023-03-11 10:47       ` Sebastian Tennant
2023-03-11 14:55         ` Jeff King
2023-03-12 18:11           ` Sebastian Tennant [this message]
2023-03-13 16:30             ` Jeff King

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

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

  git send-email \
    --in-reply-to=87pm9d6drp.fsf@sebyte.me \
    --to=sdt@sebyte.me \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.