{"thread":{"id":"15889","subject":"[BUG?] git remote rm repo nukes local refs for mirror repo","startedAt":"2008-10-14T09:05:31Z","lastAt":"2008-10-14T11:34:00Z","messageCount":4,"participants":["Michael J Gruber","Johannes Schindelin","Samuel Tardieu"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92994","messageId":"48F460DB.9030209@drmicha.warpmail.net","threadId":"15889","inReplyTo":null,"subject":"[BUG?] git remote rm repo nukes local refs for mirror repo","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-10-14T09:05:31Z","receivedAt":"2008-10-14T09:05:31Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"I just noticed the hard way that \"git remote rm repo\" nukes all local\n(mirrored) refs if repo had been setup with \"git remote add --mirror\nrepo url\".\nSome may argue that this behaviour fits the description \"deletes all\nremote tracking branches\" but I would claim it does not: mirrored\nbranches are not remote tracking branches in the proper sense.\n\nSo:\n- Is this behaviour intended?\n- If yes, how else would I remove a remote mirror configuration without\ndestroying a local repo? git config, I know, but that can't be the way.\n\nMichael\n\nTechnical:\nremote_find_tracking() in remote.c returns \"branch\" as the remote\ntracking branch of \"branch\" (itself) in a mirror setup. Is this the\nright thing to do?\n"},{"id":"92995","messageId":"alpine.DEB.1.00.0810141131130.22125@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15889","inReplyTo":"48F460DB.9030209@drmicha.warpmail.net","subject":"Re: [BUG?] git remote rm repo nukes local refs for mirror repo","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-10-14T09:32:13Z","receivedAt":"2008-10-14T09:32:13Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 14 Oct 2008, Michael J Gruber wrote:\n\n> I just noticed the hard way that \"git remote rm repo\" nukes all local \n> (mirrored) refs if repo had been setup with \"git remote add --mirror \n> repo url\".\n>\n> Some may argue that this behaviour fits the description \"deletes all \n> remote tracking branches\" but I would claim it does not: mirrored \n> branches are not remote tracking branches in the proper sense.\n\nCount me into the former group.  If you set up a \"--mirror\" repository, it \ndefeats the purpose to mix that with _true_ local branches.\n\nI'd color this a pilot error,\nDscho\n"},{"id":"92998","messageId":"2008-10-14-12-55-13+trackit+sam@rfc1149.net","threadId":"15889","inReplyTo":"alpine.DEB.1.00.0810141131130.22125@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [BUG?] git remote rm repo nukes local refs for mirror repo","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-10-14T10:55:13Z","receivedAt":"2008-10-14T10:55:13Z","isPatch":false,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"Michael> I just noticed the hard way that \"git remote rm repo\" nukes\nMichael> all local (mirrored) refs if repo had been setup with \"git\nMichael> remote add --mirror repo url\".  Some may argue that this\nMichael> behaviour fits the description \"deletes all remote tracking\nMichael> branches\" but I would claim it does not: mirrored branches\nMichael> are not remote tracking branches in the proper sense.\n\nJohannes> Count me into the former group.  If you set up a \"--mirror\"\nJohannes> repository, it defeats the purpose to mix that with _true_\nJohannes> local branches.\n\nIMO it should exit with an error and force to use \"--force\" to perform\nthe operation. The scenario I envision is a mirror becoming the\nprimary repository because the original source has disappeared. You\nwould want to remove the now-useless reference to the source, and\nsilently nuking all branches is wrong.\n\n  Sam\n-- \nSamuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/\n"},{"id":"93000","messageId":"48F483A8.4070103@drmicha.warpmail.net","threadId":"15889","inReplyTo":"alpine.DEB.1.00.0810141131130.22125@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [BUG?] git remote rm repo nukes local refs for mirror repo","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-10-14T11:34:00Z","receivedAt":"2008-10-14T11:34:00Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 14.10.2008 11:32:\n> Hi,\n> \n> On Tue, 14 Oct 2008, Michael J Gruber wrote:\n> \n>> I just noticed the hard way that \"git remote rm repo\" nukes all local \n>> (mirrored) refs if repo had been setup with \"git remote add --mirror \n>> repo url\".\n>>\n>> Some may argue that this behaviour fits the description \"deletes all \n>> remote tracking branches\" but I would claim it does not: mirrored \n>> branches are not remote tracking branches in the proper sense.\n> \n> Count me into the former group.  If you set up a \"--mirror\" repository, it \n> defeats the purpose to mix that with _true_ local branches.\n> \n> I'd color this a pilot error,\n> Dscho\n\nOK, I'll give some background about the motivation:\n\nI have a \"local\" repo.\nI want to create a \"backup repo\" which contains the same branches\n(including proper remotes, svn remotes).\n\nSo, I create an empty bare repo somewhere (say store:backuprepo.git),\nand in the local repo I do:\n\ngit remote add --mirror backup store:backuprepo.git\ngit push backup\n\nI need \"mirror=true\" because otherwise branches are not created\nautomatically (on push) on the remote side. I need the '+refs/*:refs/*'\nrefspec because otherwise not all refs are mirrored. But now I can't use\n\"git remote rm backup\" to remove the configuration because that would\ntake away all my local branches, too.\n\nInstead, I could set up things with\n\ngit remote add backup store:backuprepo.git\ngit config remote.backup.push '+refs/*:refs/*'\n\nThen all branches are mirrored on the remote automatically. But\ninteresting things happen after fetch and push... Read \"recursion\". So,\nin order to avoid any remote/backup/foo branches on the local side I\nwould have to use\n\ngit remote add backup store:backuprepo.git\ngit config remote.backup.push '+refs/*:refs/*'\ngit config --unset remote.backup.fetch\n\nin order to create a \"backup remote\" configuration. Maybe I'm just being\ndense (which is actually OK for a functional analyst); I'd be happy\nabout any more direct solution. At least I think there should be one, a\nbackup bare remote mirror is a common use case, and the config massaging\nabove is not something to recommend to novice users.\n\nMichael\n\nP.S.: Yeah I know, git's no backup tool, there's rsync... ;)\n"}]}