svnadmin equivalent?

Marc Branchaud marcnarc at gmail.com
Fri Dec 11 15:49:08 UTC 2020


On 2020-12-10 11:37 p.m., Warner Losh wrote:
> On Thu, Dec 10, 2020, 9:35 PM Konstantin Belousov <kostikbel at 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

		M.



More information about the freebsd-git mailing list