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

Re: [BUG?] git remote rm repo nukes local refs for mirror repo

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Oct 14, 2008, 11:34 UTC
Message-ID
<48F483A8.4070103@drmicha.warpmail.net>
In-Reply-To
<alpine.DEB.1.00.0810141131130.22125@pacific.mpi-cbg.de.mpi-cbg.de>
Johannes Schindelin venit, vidit, dixit 14.10.2008 11:32:
Show 17 quoted lines
> Hi,
> 
> On Tue, 14 Oct 2008, Michael J Gruber wrote:
> 
>> I just noticed the hard way that "git remote rm repo" nukes all local 
>> (mirrored) refs if repo had been setup with "git remote add --mirror 
>> repo url".
>>
>> Some may argue that this behaviour fits the description "deletes all 
>> remote tracking branches" but I would claim it does not: mirrored 
>> branches are not remote tracking branches in the proper sense.
> 
> Count me into the former group.  If you set up a "--mirror" repository, it 
> defeats the purpose to mix that with _true_ local branches.
> 
> I'd color this a pilot error,
> Dscho
OK, I'll give some background about the motivation:

I have a "local" repo. I want to create a "backup repo" which contains the same branches (including proper remotes, svn remotes).

So, I create an empty bare repo somewhere (say store:backuprepo.git), and in the local repo I do:

git remote add --mirror backup store:backuprepo.git git push backup

I need "mirror=true" because otherwise branches are not created automatically (on push) on the remote side. I need the '+refs/*:refs/*' refspec because otherwise not all refs are mirrored. But now I can't use "git remote rm backup" to remove the configuration because that would take away all my local branches, too.

Instead, I could set up things with

git remote add backup store:backuprepo.git git config remote.backup.push '+refs/*:refs/*'

Then all branches are mirrored on the remote automatically. But interesting things happen after fetch and push... Read "recursion". So, in order to avoid any remote/backup/foo branches on the local side I would have to use

git remote add backup store:backuprepo.git git config remote.backup.push '+refs/*:refs/*' git config --unset remote.backup.fetch

in order to create a "backup remote" configuration. Maybe I'm just being dense (which is actually OK for a functional analyst); I'd be happy about any more direct solution. At least I think there should be one, a backup bare remote mirror is a common use case, and the config massaging above is not something to recommend to novice users.

Michael
P.S.: Yeah I know, git's no backup tool, there's rsync... ;)
Previous: Samuel Tardieu
Message 4 of 4 in “[BUG?] git remote rm repo nukes local refs for mirror repo”
  1. Michael J GruberOct 14, 2008
  2. Johannes SchindelinOct 14, 2008
  3. Samuel TardieuOct 14, 2008
  4. Michael J GruberOct 14, 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.