Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Dec 2020 09:32:34 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Marc Branchaud <marcnarc@gmail.com>
Cc:        Konstantin Belousov <kostikbel@gmail.com>, git@freebsd.org
Subject:   Re: svnadmin equivalent?
Message-ID:  <CANCZdfrVku02pOZTHVZnoAurhp59O4L7JWTjzPWg33DfUHekJQ@mail.gmail.com>
In-Reply-To: <8e48e2ea-59d8-d2fd-4e25-e12088ff3a36@gmail.com>
References:  <20201210223443.GA64504@freefall.freebsd.org> <CAKBkRUwjJF9nY=JyNkZgGq67QBKhmVhu61YU_Gt_nz3uhvYf%2Bw@mail.gmail.com> <X9LuAwJlrnR2mzRS@kib.kiev.ua> <CAKBkRUziop1eipR3MA5GyzNaTF1Yn=r3Bh77jRB_VxgmUqppmQ@mail.gmail.com> <X9L29kI8IEY%2BlHrh@kib.kiev.ua> <CANCZdfojavQj3oJXUdW5rb%2B6nL=jSMvC=-3KUMJDc1yYXSEtkg@mail.gmail.com> <8e48e2ea-59d8-d2fd-4e25-e12088ff3a36@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Dec 11, 2020 at 8:49 AM Marc Branchaud <marcnarc@gmail.com> wrote:

> On 2020-12-10 11:37 p.m., Warner Losh wrote:
> > On Thu, Dec 10, 2020, 9:35 PM Konstantin Belousov <kostikbel@gmail.com>
> > wrote:
> >>
> >> Can we have it scripted, per repo, and scripts available somewhere ?
> >> It is convoluted list of per-repo branches.  I want a simple means to
> >> run something and get the guaranteed clone of all material from the
> repo.
> >>
> >
> > git clone --mirror
>
> "git clone --mirror" fetches everything, but it has two potentially
> confusing side-effects:
>
> * Mirroring creates a "bare" local repository without any checked-out
> files (all you get are the contents of the remote's .git/ directory).
> This doesn't mean it's unusable, just that it's not *directly* usable
> (for example, see Mathieu's suggestion about "git worktree add").
>
> * More subtly, mirroring also removes the distinction between your local
> branches and the remote repo's branches.  So you don't end up with any
> "origin/XXXX" branches.  This can be very confusing when you've made
> commits to your local "main" branch that get clobbered by your next fetch.
>
> Here's how to get absolutely everything in your regular-clone'd repo
> while preserving the "origin/" namespace for the official repo's branches:
>
> # First reset the config to the default that a non-mirror clone creates:
> git config --replace-all remote.origin.fetch
> '+refs/heads/*:refs/remotes/origin/*'
> (WARNING: If you've configured other remote.origin.fetch specs, like to
> retrieve the "notes" namespace, this command will remove those and
> you'll have to re-configure them.)
>
> # Then configure fetch to also get all the other stuff:
> git config --add remote.origin.fetch '+refs/*:refs/origin/*'
>
> The default setting is important to make commands that interpret branch
> names work properly with remote ("origin/<branchname>") branches,
> because they look for remote branch names under the refs/remotes/
> namespace.
>
> The second setting puts *every* reference in the remote repo into your
> repo's "refs/origin/" namespace.  Since nothing in git uses the
> "refs/origin/" namespace we're free to do whatever we want with it
> without breaking anything.  The slight inconvenience is that to access a
> non-branch, non-tag symbol we have to prefix it with "refs/origin/" (not
> just "origin/"):
>         git show refs/origin/internal/admin:mentors
>         git log refs/origin/vendor/zlib/1.2.10
>         git checkout -b my-arm64-hacks refs/origin/projects/arm64
>

That;s good advice. I'll add this to my FAQ.

It is a bit like checking out from http://svn.freebsd.org/base, though,
which gets a lot of chaff...

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrVku02pOZTHVZnoAurhp59O4L7JWTjzPWg33DfUHekJQ>