{"thread":{"id":"46149","subject":"How to git push mirror local refs only?","startedAt":"2017-06-09T16:12:32Z","lastAt":"2017-06-19T17:58:54Z","messageCount":4,"participants":["Robert Dailey","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"321834","messageId":"CAHd499BBNsai4SScOe6kADsgbGRLyGnDKyUcm8LZL-w8c9Webw@mail.gmail.com","threadId":"46149","inReplyTo":null,"subject":"How to git push mirror local refs only?","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2017-06-09T16:12:22Z","receivedAt":"2017-06-09T16:12:32Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"So I want to update my remote fork with all my local branches.\nNormally I'd do this:\n\n$ git push --mirror fork\n\nHowever this will also push everything under `refs/remotes` which I do\nnot want. And it fails if I specify a refspec parameter with --mirror.\n\nIs there a way to achieve this through one or more git commands? Note\nI'm doing this on a non-bare clone and have to keep it that way since\nI'm pushing branches I actively work on.\n\nAn intrinsic benefit of what I'm trying to do is that the mirror\ncommand will also batch delete branches on the remote that do not\nexist locally, which is behavior I want since I do not need them\nanymore.\n\nThanks in advance.\n"},{"id":"321868","messageId":"xmqqpoec4nib.fsf@gitster.mtv.corp.google.com","threadId":"46149","inReplyTo":"CAHd499BBNsai4SScOe6kADsgbGRLyGnDKyUcm8LZL-w8c9Webw@mail.gmail.com","subject":"Re: How to git push mirror local refs only?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-10T01:53:00Z","receivedAt":"2017-06-10T01:53:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Dailey <rcdailey.lists@gmail.com> writes:\n\n> So I want to update my remote fork with all my local branches.\n> Normally I'd do this:\n>\n> $ git push --mirror fork\n>\n> However this will also push everything under `refs/remotes` which I do\n> not want. And it fails if I specify a refspec parameter with --mirror.\n>\n> Is there a way to achieve this through one or more git commands? Note\n> I'm doing this on a non-bare clone and have to keep it that way since\n> I'm pushing branches I actively work on.\n>\n> An intrinsic benefit of what I'm trying to do is that the mirror\n> command will also batch delete branches on the remote that do not\n> exist locally, which is behavior I want since I do not need them\n> anymore.\n\nSomething along this line in your .git/config:\n\n\t[remote \"fork\"]\n\t\turl = ...\n\t\tpush = refs/heads/*:refs/heads/*\n\nand then\n\n\t$ git push --prune --follow-tags fork\n\n\n\n\n\n"},{"id":"322564","messageId":"CAHd499Aft6yE=8f8DGRVxMYNR5kg6AVs3tECVtz1VDdwFeL5fg@mail.gmail.com","threadId":"46149","inReplyTo":"xmqqpoec4nib.fsf@gitster.mtv.corp.google.com","subject":"Re: How to git push mirror local refs only?","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2017-06-19T14:20:22Z","receivedAt":"2017-06-19T14:20:28Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Fri, Jun 9, 2017 at 8:53 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Robert Dailey <rcdailey.lists@gmail.com> writes:\n>\n>> So I want to update my remote fork with all my local branches.\n>> Normally I'd do this:\n>>\n>> $ git push --mirror fork\n>>\n>> However this will also push everything under `refs/remotes` which I do\n>> not want. And it fails if I specify a refspec parameter with --mirror.\n>>\n>> Is there a way to achieve this through one or more git commands? Note\n>> I'm doing this on a non-bare clone and have to keep it that way since\n>> I'm pushing branches I actively work on.\n>>\n>> An intrinsic benefit of what I'm trying to do is that the mirror\n>> command will also batch delete branches on the remote that do not\n>> exist locally, which is behavior I want since I do not need them\n>> anymore.\n>\n> Something along this line in your .git/config:\n>\n>         [remote \"fork\"]\n>                 url = ...\n>                 push = refs/heads/*:refs/heads/*\n>\n> and then\n>\n>         $ git push --prune --follow-tags fork\n\nSorry for the late reply, I was out of town all last week. Thanks for\nyour help. Does this serve as a good general default? I can't imagine\na case where I'd ever want to push something inside refs/remotes.\n"},{"id":"322591","messageId":"xmqq4lvbuaef.fsf@gitster.mtv.corp.google.com","threadId":"46149","inReplyTo":"CAHd499Aft6yE=8f8DGRVxMYNR5kg6AVs3tECVtz1VDdwFeL5fg@mail.gmail.com","subject":"Re: How to git push mirror local refs only?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-19T17:58:48Z","receivedAt":"2017-06-19T17:58:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Dailey <rcdailey.lists@gmail.com> writes:\n\n> On Fri, Jun 9, 2017 at 8:53 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Robert Dailey <rcdailey.lists@gmail.com> writes:\n>>\n>>> So I want to update my remote fork with all my local branches.\n>>> Normally I'd do this:\n>>>\n>>> $ git push --mirror fork\n>>> ...\n>> Something along this line in your .git/config:\n>>\n>>         [remote \"fork\"]\n>>                 url = ...\n>>                 push = refs/heads/*:refs/heads/*\n>>\n>> and then\n>>\n>>         $ git push --prune --follow-tags fork\n>\n> Sorry for the late reply, I was out of town all last week. Thanks for\n> your help. Does this serve as a good general default? I can't imagine\n> a case where I'd ever want to push something inside refs/remotes.\n\nIt may, as a good general default to something other than --mirror,\nperhaps.  When I ask for mirroring the state of my repository, I'd\nexpect it to preserve as much state as possible, including the tips\nof histories I received from elsewhere.\n"}]}