Re: How to mirror and augment a git repository

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoth Jeff King <peff@xxxxxxxx>
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux