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

[RFC] Moving "git remote add --mirror blah" functionality to "git clone --bare --origin=blah"

From
Paolo Bonzini <bonzini@gnu.org>
Date
Apr 23, 2008, 08:28 UTC
Message-ID
<480EF334.1090907@gnu.org>

In the thread "git remote update -> rejected" Junio and Johannes came to the conclusion that "--mirror means that you do not have local branches", because "you give control away to the other end on the ref namespace". Furthermore, it was agreed that --mirror currently makes sense mostly (or only?) on a bare repository.

 From here I gather that if you have "git remote add --mirror", most 
likely the mirrored repository will be the only remote you have.  There 
is in general no point in having other remotes in a bare repository. 
And so there is no loss of generality if this remote is the "origin" remote.
Hence, my proposal is:
1) Add an option to "git clone", to be used with --bare, to create a 
mirror.  --bare already leaves the original refs in place, without 
moving them under refs/remotes/origin, so it makes sense to optionally 
create the remote.

Actually you don't need to add a new option. Right now, specifying -o/--origin together with --bare would give an error; in my proposal, if you had "--bare --origin=source" a remote would be created in the config file like this:

[remote "source"]
	url = ...
	fetch = +refs/*:refs/*
2) Modify the --mirror option to "git remote add", so that it creates a 
remote *acting as a mirror of this one*.  The config would look like this:
[remote "mirror"]
         url = ...
         fetch = +refs/heads/*:refs/remotes/mirror/*
         push = +refs/heads/*:refs/heads/*
         push = +refs/tags/*:refs/tags/*
         mirror

Now, I know that this is not what was proposed in the original --mirror thread, and it is backwards-incompatible. On the other hand, I think it has several advantages:

1) it does not add special cases such as "--mirror is only to be used in 
a --bare repository".  It moves the functionality to a combination of 
options that used to give an error.
2) it provides an easy-to-use UI to create a mirror of this repository 
somewhere.  With a patch I already posted, "git push" would 
automatically update this mirror.
3) overall, I think it makes a lot of sense: "git remote add" is about 
adding one remote of many, and "git clone" is about setting up a single 
special remote.  Now, you can have many remotes that are 
mirrored-from-here, while you can only have one remote that is 
mirrored-to-here.  So, I believe that "git remote add" should add 
mirrored-from-here remotes, while "git clone" should be used to create a 
mirrored-to-here remote.
Opinions?
Paolo
Next: Johannes Schindelin
Message 1 of 9 in “[RFC] Moving "git remote add --mirror blah" functionality to "git clone --bare --origin=blah"”
  1. Paolo BonziniApr 23, 2008
  2. Johannes SchindelinApr 23, 2008
  3. Junio C HamanoApr 23, 2008
  4. Daniel BarkalowApr 23, 2008
  5. Jeff KingApr 23, 2008
  6. Paolo BonziniApr 23, 2008
  7. Junio C HamanoApr 23, 2008
  8. Johannes SchindelinApr 23, 2008
  9. Paolo BonziniApr 24, 2008

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.