{"thread":{"id":"49911","subject":"Simple git push --tags deleted all branches","startedAt":"2018-11-28T16:51:18Z","lastAt":"2018-12-04T19:01:26Z","messageCount":6,"participants":["Mateusz Loskot","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"364231","messageId":"CABUeae-e33Jc4s4MezjhpVsEJ_0sO8QZ1mpa1z_79ZGuQWM-Xw@mail.gmail.com","threadId":"49911","inReplyTo":null,"subject":"Simple git push --tags deleted all branches","fromName":"Mateusz Loskot","fromEmail":"mateusz@loskot.net","sentAt":"2018-11-28T16:50:49Z","receivedAt":"2018-11-28T16:51:18Z","isPatch":false,"sender":{"key":"mateusz@loskot.net","avatar":"https://gravatar.com/avatar/fe5a0ce8995d4986f5c46aad6353e21717808da58e4bc710da1a100e247be239?d=mp&s=160"},"body":"Hi,\n\n(using git version 2.19.2.windows.1)\n\nI've just encountered one of those WTH moments.\n\nI have a bare repository\n\ncore.git (BARE:master) $ git branch\n  1.0\n  2.0\n* master\n\ncore.git (BARE:master) $ git tag\n1.0.1651\n1.0.766\n2.0.1103\n2.0.1200\n\nI published the repo using: git push --all --follow-tags\n\nThis succeeded, but there seem to be no tags pushed, just branches.\nSo, I followed with\n\ncore.git (BARE:master) $ git push --tags\nTo XXX\n - [deleted]               1.0\n - [deleted]               2.0\n ! [remote rejected]       master (refusing to delete the current\nbranch: refs/heads/master)\nerror: failed to push some refs to 'XXX'\n\nAnd, I've found out that all branches and tags have been\nwiped in both, local repo and remote :)\n\nI restored the repo and tried out\n\ngit push origin 1.0\ngit push origin --tags\n\nand this time both succeeded, without wiping out any refs.\n\nCould anyone help me to understand why remote-less\n\ngit push --tags\n\nis/was so dangerous and unforgiving?!\n\nBest regards,\n-- \nMateusz Loskot, http://mateusz.loskot.net\n"},{"id":"364233","messageId":"CABUeae-eOFGxAHWuhP50GE8fAMnDH7rfqSV8MSVZ2ZnYH-2W6Q@mail.gmail.com","threadId":"49911","inReplyTo":"CABUeae-e33Jc4s4MezjhpVsEJ_0sO8QZ1mpa1z_79ZGuQWM-Xw@mail.gmail.com","subject":"Re: Simple git push --tags deleted all branches","fromName":"Mateusz Loskot","fromEmail":"mateusz@loskot.net","sentAt":"2018-11-28T18:13:14Z","receivedAt":"2018-11-28T18:13:43Z","isPatch":false,"sender":{"key":"mateusz@loskot.net","avatar":"https://gravatar.com/avatar/fe5a0ce8995d4986f5c46aad6353e21717808da58e4bc710da1a100e247be239?d=mp&s=160"},"body":"On Wed, 28 Nov 2018 at 17:50, Mateusz Loskot <mateusz@loskot.net> wrote:\n>\n> (using git version 2.19.2.windows.1)\n> [...]\n> I restored the repo and tried out\n>\n> git push origin 1.0\n> git push origin --tags\n>\n> and this time both succeeded, without wiping out any refs.\n\nAnd, to my surprise, this pushed all branches and all tags:\n\ngit push --all origin\n\nSo, I  did not have to run follow with tags push only using\n\ngit push --tags origin\n\nHas anything changes in [1] that now\n--all\nPush all branches ...AND tags?\n\n[1] https://git-scm.com/docs/git-push#git-push---all\n\nBest regards,\n-- \nMateusz Loskot, http://mateusz.loskot.net\n"},{"id":"364330","messageId":"87y39cx6wt.fsf@evledraar.gmail.com","threadId":"49911","inReplyTo":"CABUeae-e33Jc4s4MezjhpVsEJ_0sO8QZ1mpa1z_79ZGuQWM-Xw@mail.gmail.com","subject":"Re: Simple git push --tags deleted all branches","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-11-29T15:03:30Z","receivedAt":"2018-11-29T15:03:36Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Nov 28 2018, Mateusz Loskot wrote:\n\n> Hi,\n>\n> (using git version 2.19.2.windows.1)\n>\n> I've just encountered one of those WTH moments.\n>\n> I have a bare repository\n>\n> core.git (BARE:master) $ git branch\n>   1.0\n>   2.0\n> * master\n>\n> core.git (BARE:master) $ git tag\n> 1.0.1651\n> 1.0.766\n> 2.0.1103\n> 2.0.1200\n>\n> I published the repo using: git push --all --follow-tags\n>\n> This succeeded, but there seem to be no tags pushed, just branches.\n> So, I followed with\n>\n> core.git (BARE:master) $ git push --tags\n> To XXX\n>  - [deleted]               1.0\n>  - [deleted]               2.0\n>  ! [remote rejected]       master (refusing to delete the current\n> branch: refs/heads/master)\n> error: failed to push some refs to 'XXX'\n>\n> And, I've found out that all branches and tags have been\n> wiped in both, local repo and remote :)\n>\n> I restored the repo and tried out\n>\n> git push origin 1.0\n> git push origin --tags\n>\n> and this time both succeeded, without wiping out any refs.\n>\n> Could anyone help me to understand why remote-less\n>\n> git push --tags\n>\n> is/was so dangerous and unforgiving?!\n\nSince nobody's replied yet, I can't see what's going on here from the\ninfo you've provided. My guess is that you have something \"mirror\" set\non the remote.\n\nIt seems you can't share the repo or its URL, but could you share the\nscrubbed output of 'git config -l --show-origin' when run inside this\nrepository?\n"},{"id":"364332","messageId":"CABUeae_VVtbj0JCRyUuqf=uaPFXkmHwHpYyapH4H5A_cQSQsdA@mail.gmail.com","threadId":"49911","inReplyTo":"87y39cx6wt.fsf@evledraar.gmail.com","subject":"Re: Simple git push --tags deleted all branches","fromName":"Mateusz Loskot","fromEmail":"mateusz@loskot.net","sentAt":"2018-11-29T15:18:27Z","receivedAt":"2018-11-29T15:18:58Z","isPatch":false,"sender":{"key":"mateusz@loskot.net","avatar":"https://gravatar.com/avatar/fe5a0ce8995d4986f5c46aad6353e21717808da58e4bc710da1a100e247be239?d=mp&s=160"},"body":"On Thu, 29 Nov 2018 at 16:03, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> On Wed, Nov 28 2018, Mateusz Loskot wrote:\n> >\n> > (using git version 2.19.2.windows.1)\n> >\n> > I've just encountered one of those WTH moments.\n> >\n> > I have a bare repository\n> >\n> > core.git (BARE:master) $ git branch\n> >   1.0\n> >   2.0\n> > * master\n> >\n> > core.git (BARE:master) $ git tag\n> > 1.0.1651\n> > 1.0.766\n> > 2.0.1103\n> > 2.0.1200\n> >\n> > I published the repo using: git push --all --follow-tags\n> >\n> > This succeeded, but there seem to be no tags pushed, just branches.\n> > So, I followed with\n> >\n> > core.git (BARE:master) $ git push --tags\n> > To XXX\n> >  - [deleted]               1.0\n> >  - [deleted]               2.0\n> >  ! [remote rejected]       master (refusing to delete the current\n> > branch: refs/heads/master)\n> > error: failed to push some refs to 'XXX'\n> >\n> > And, I've found out that all branches and tags have been\n> > wiped in both, local repo and remote :)\n> >\n> > I restored the repo and tried out\n> >\n> > git push origin 1.0\n> > git push origin --tags\n> >\n> > and this time both succeeded, without wiping out any refs.\n> >\n> > Could anyone help me to understand why remote-less\n> >\n> > git push --tags\n> >\n> > is/was so dangerous and unforgiving?!\n>\n> Since nobody's replied yet, I can't see what's going on here from the\n> info you've provided. My guess is that you have something \"mirror\" set\n> on the remote.\n\nThank you for responding.\n\nThe git push --tags hugely surprised me, and here is genuine screenshot\nhttps://twitter.com/mloskot/status/1068072285846859776\n\n> It seems you can't share the repo or its URL, but could you share the\n> scrubbed output of 'git config -l --show-origin' when run inside this\n> repository?\n\nHere is complete output. I have not stripped the basics like aliases,\njust in case.\n\n```\ncore-external-metadata.git (BARE:master) $ git config -l --show-origin\nfile:\"C:\\\\ProgramData/Git/config\"       core.symlinks=false\nfile:\"C:\\\\ProgramData/Git/config\"       core.autocrlf=true\nfile:\"C:\\\\ProgramData/Git/config\"       color.diff=auto\nfile:\"C:\\\\ProgramData/Git/config\"       color.status=auto\nfile:\"C:\\\\ProgramData/Git/config\"       color.branch=auto\nfile:\"C:\\\\ProgramData/Git/config\"       color.interactive=true\nfile:\"C:\\\\ProgramData/Git/config\"       help.format=html\nfile:\"C:\\\\ProgramData/Git/config\"       http.sslcainfo=C:/Program\nFiles/Git/mingw64/ssl/certs/ca-bundle.crt\nfile:\"C:\\\\ProgramData/Git/config\"       diff.astextplain.textconv=astextplain\nfile:\"C:\\\\ProgramData/Git/config\"       rebase.autosquash=true\nfile:C:/Program Files/Git/mingw64/etc/gitconfig\nhttp.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt\nfile:C:/Program Files/Git/mingw64/etc/gitconfig http.sslbackend=openssl\nfile:C:/Program Files/Git/mingw64/etc/gitconfig\ndiff.astextplain.textconv=astextplain\nfile:C:/Program Files/Git/mingw64/etc/gitconfig\nfilter.lfs.clean=git-lfs clean -- %f\nfile:C:/Program Files/Git/mingw64/etc/gitconfig\nfilter.lfs.smudge=git-lfs smudge -- %f\nfile:C:/Program Files/Git/mingw64/etc/gitconfig\nfilter.lfs.process=git-lfs filter-process\nfile:C:/Program Files/Git/mingw64/etc/gitconfig filter.lfs.required=true\nfile:C:/Program Files/Git/mingw64/etc/gitconfig credential.helper=manager\nfile:C:/Users/mateuszl/.gitconfig       user.name=Mateusz Łoskot\nfile:C:/Users/mateuszl/.gitconfig       user.email=mateusz@loskot.net\nfile:C:/Users/mateuszl/.gitconfig       github.user=mloskot\nfile:C:/Users/mateuszl/.gitconfig       core.editor=vim\nfile:C:/Users/mateuszl/.gitconfig       color.branch=auto\nfile:C:/Users/mateuszl/.gitconfig       color.diff=auto\nfile:C:/Users/mateuszl/.gitconfig       color.status=auto\nfile:C:/Users/mateuszl/.gitconfig       color.ui=auto\nfile:C:/Users/mateuszl/.gitconfig       alias.br=branch\nfile:C:/Users/mateuszl/.gitconfig       alias.bv=branch -vv\nfile:C:/Users/mateuszl/.gitconfig       alias.brv=branch -vv\nfile:C:/Users/mateuszl/.gitconfig       alias.bra=branch -a\nfile:C:/Users/mateuszl/.gitconfig       alias.ci=commit --verbose\nfile:C:/Users/mateuszl/.gitconfig       alias.cia=commit --verbose --amend\nfile:C:/Users/mateuszl/.gitconfig       alias.ciae=commit --verbose\n--amend --no-edit\nfile:C:/Users/mateuszl/.gitconfig       alias.co=checkout\nfile:C:/Users/mateuszl/.gitconfig       alias.dc=diff --cached\nfile:C:/Users/mateuszl/.gitconfig       alias.df=diff\nfile:C:/Users/mateuszl/.gitconfig       alias.gf=flow\nfile:C:/Users/mateuszl/.gitconfig       alias.lg=log --color --graph\n--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)\n%C(bold blue)<%an>%Creset' --abbrev-commit\nfile:C:/Users/mateuszl/.gitconfig       alias.lol=log --graph\n--decorate --pretty=oneline --abbrev-commit\nfile:C:/Users/mateuszl/.gitconfig       alias.lola=log --graph\n--decorate --pretty=oneline --abbrev-commit --all\nfile:C:/Users/mateuszl/.gitconfig       alias.ls=ls-files\nfile:C:/Users/mateuszl/.gitconfig       alias.lst=lfs status\nfile:C:/Users/mateuszl/.gitconfig       alias.rt=remote\nfile:C:/Users/mateuszl/.gitconfig       alias.rtv=remote -v\nfile:C:/Users/mateuszl/.gitconfig       alias.st=status\nfile:C:/Users/mateuszl/.gitconfig       alias.ghclm=!sh -c 'git log\n$1...$2  --pretty=format:\"* [view](http://github.com/$3/$4/commit/%H)\n- %s\"' -\nfile:C:/Users/mateuszl/.gitconfig       alias.ign=ls-files -o -i\n--exclude-standard\nfile:C:/Users/mateuszl/.gitconfig\nalias.prune-branches-origin=!git remote prune origin && git branch -vv\n| grep ': gone]' | awk '{print $1}' | xargs -r git branch -D\nfile:C:/Users/mateuszl/.gitconfig\nalias.prune-branches-mloskot=!git remote prune mloskot && git branch\n-vv | grep ': gone]' | awk '{print $1}' | xargs -r git branch -D\nfile:C:/Users/mateuszl/.gitconfig       alias.hist=log\n--pretty=format:'%h %ad | %s%d [%an]' --graph --date=short\nfile:C:/Users/mateuszl/.gitconfig       commit.template=~/.gitmessage\nfile:C:/Users/mateuszl/.gitconfig       credential.helper=manager\nfile:C:/Users/mateuszl/.gitconfig       filter.lfs.clean=git-lfs clean -- %f\nfile:C:/Users/mateuszl/.gitconfig       filter.lfs.smudge=git-lfs\nsmudge --skip -- %f\nfile:C:/Users/mateuszl/.gitconfig       filter.lfs.process=git-lfs\nfilter-process --skip\nfile:C:/Users/mateuszl/.gitconfig       filter.lfs.required=true\nfile:config     core.repositoryformatversion=0\nfile:config     core.filemode=false\nfile:config     core.bare=true\nfile:config     core.symlinks=false\nfile:config     core.ignorecase=true\nfile:config     remote.origin.url=https://xxx.com/core-external-metadata.git\nfile:config     remote.origin.fetch=+refs/*:refs/*\nfile:config     remote.origin.mirror=true\nfile:config\nlfs.https://xxx.com/core-external-metadata.git/info/lfs.access=basic\n```\n\nBest regards,\n-- \nMateusz Loskot, http://mateusz.loskot.net\n"},{"id":"364336","messageId":"87va4fyjtv.fsf@evledraar.gmail.com","threadId":"49911","inReplyTo":"CABUeae_VVtbj0JCRyUuqf=uaPFXkmHwHpYyapH4H5A_cQSQsdA@mail.gmail.com","subject":"Re: Simple git push --tags deleted all branches","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-11-29T15:39:08Z","receivedAt":"2018-11-29T15:39:13Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Nov 29 2018, Mateusz Loskot wrote:\n\n> On Thu, 29 Nov 2018 at 16:03, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n>> On Wed, Nov 28 2018, Mateusz Loskot wrote:\n>> >\n>> > (using git version 2.19.2.windows.1)\n>> >\n>> > I've just encountered one of those WTH moments.\n>> >\n>> > I have a bare repository\n>> >\n>> > core.git (BARE:master) $ git branch\n>> >   1.0\n>> >   2.0\n>> > * master\n>> >\n>> > core.git (BARE:master) $ git tag\n>> > 1.0.1651\n>> > 1.0.766\n>> > 2.0.1103\n>> > 2.0.1200\n>> >\n>> > I published the repo using: git push --all --follow-tags\n>> >\n>> > This succeeded, but there seem to be no tags pushed, just branches.\n>> > So, I followed with\n>> >\n>> > core.git (BARE:master) $ git push --tags\n>> > To XXX\n>> >  - [deleted]               1.0\n>> >  - [deleted]               2.0\n>> >  ! [remote rejected]       master (refusing to delete the current\n>> > branch: refs/heads/master)\n>> > error: failed to push some refs to 'XXX'\n>> >\n>> > And, I've found out that all branches and tags have been\n>> > wiped in both, local repo and remote :)\n>> >\n>> > I restored the repo and tried out\n>> >\n>> > git push origin 1.0\n>> > git push origin --tags\n>> >\n>> > and this time both succeeded, without wiping out any refs.\n>> >\n>> > Could anyone help me to understand why remote-less\n>> >\n>> > git push --tags\n>> >\n>> > is/was so dangerous and unforgiving?!\n>>\n>> Since nobody's replied yet, I can't see what's going on here from the\n>> info you've provided. My guess is that you have something \"mirror\" set\n>> on the remote.\n>\n> Thank you for responding.\n>\n> The git push --tags hugely surprised me, and here is genuine screenshot\n> https://twitter.com/mloskot/status/1068072285846859776\n>\n>> It seems you can't share the repo or its URL, but could you share the\n>> scrubbed output of 'git config -l --show-origin' when run inside this\n>> repository?\n>\n> Here is complete output. I have not stripped the basics like aliases,\n> just in case.\n\nRight, it's because you used --mirror, the important bit:\n\n> file:config     remote.origin.url=https://xxx.com/core-external-metadata.git\n> file:config     remote.origin.fetch=+refs/*:refs/*\n> file:config     remote.origin.mirror=true\n> file:config\n\nI.e. you have cloned with the --mirror flag, this is what it's supposed\nto do: https://git-scm.com/docs/git-clone#git-clone---mirror\nhttps://git-scm.com/docs/git-fetch#git-fetch---prune\n\nI.e. you push and git tries to mirror the refs you have locally to the\nremote, including pruning stuff in the remote.\n\nThis is useful, but not what you wanted here. It's used for e.g. making\nan up-to-date copy of a repo from server A to server B in HA setups\nwhere you'd like to fail over to server B and get the same refs you had\non A.\n"},{"id":"364573","messageId":"CABUeae9w4kfrPp3ZkdYpBb3o5cRqdxhvMixUAjVLQzS+2LYF=w@mail.gmail.com","threadId":"49911","inReplyTo":"87va4fyjtv.fsf@evledraar.gmail.com","subject":"Re: Simple git push --tags deleted all branches","fromName":"Mateusz Loskot","fromEmail":"mateusz@loskot.net","sentAt":"2018-12-04T19:00:55Z","receivedAt":"2018-12-04T19:01:26Z","isPatch":false,"sender":{"key":"mateusz@loskot.net","avatar":"https://gravatar.com/avatar/fe5a0ce8995d4986f5c46aad6353e21717808da58e4bc710da1a100e247be239?d=mp&s=160"},"body":"On Thu, 29 Nov 2018 at 16:39, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> On Thu, Nov 29 2018, Mateusz Loskot wrote:\n> > On Thu, 29 Nov 2018 at 16:03, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> >> On Wed, Nov 28 2018, Mateusz Loskot wrote:\n> >> >\n> >> > (using git version 2.19.2.windows.1)\n> >> >\n> >> > I've just encountered one of those WTH moments.\n> >> >\n> >> > I have a bare repository\n> >> >\n> >> > core.git (BARE:master) $ git branch\n> >> >   1.0\n> >> >   2.0\n> >> > * master\n> >> >\n> >> > core.git (BARE:master) $ git tag\n> >> > 1.0.1651\n> >> > 1.0.766\n> >> > 2.0.1103\n> >> > 2.0.1200\n> >> >\n> >> > I published the repo using: git push --all --follow-tags\n> >> >\n> >> > This succeeded, but there seem to be no tags pushed, just branches.\n> >> > So, I followed with\n> >> >\n> >> > core.git (BARE:master) $ git push --tags\n> >> > To XXX\n> >> >  - [deleted]               1.0\n> >> >  - [deleted]               2.0\n> >> >  ! [remote rejected]       master (refusing to delete the current\n> >> > branch: refs/heads/master)\n> >> > error: failed to push some refs to 'XXX'\n> >> >\n> >> > And, I've found out that all branches and tags have been\n> >> > wiped in both, local repo and remote :)\n> >> >\n> >> > I restored the repo and tried out\n> >> >\n> >> > git push origin 1.0\n> >> > git push origin --tags\n> >> >\n> >> > and this time both succeeded, without wiping out any refs.\n> >> >\n> >> > Could anyone help me to understand why remote-less\n> >> >\n> >> > git push --tags\n> >> >\n> >> > is/was so dangerous and unforgiving?!\n> >>\n> >> Since nobody's replied yet, I can't see what's going on here from the\n> >> info you've provided. My guess is that you have something \"mirror\" set\n> >> on the remote.\n> >\n> > Thank you for responding.\n> >\n> > The git push --tags hugely surprised me, and here is genuine screenshot\n> > https://twitter.com/mloskot/status/1068072285846859776\n> >\n> >> It seems you can't share the repo or its URL, but could you share the\n> >> scrubbed output of 'git config -l --show-origin' when run inside this\n> >> repository?\n> >\n> > Here is complete output. I have not stripped the basics like aliases,\n> > just in case.\n>\n> Right, it's because you used --mirror, the important bit:\n>\n> > file:config     remote.origin.url=https://xxx.com/core-external-metadata.git\n> > file:config     remote.origin.fetch=+refs/*:refs/*\n> > file:config     remote.origin.mirror=true\n> > file:config\n>\n> I.e. you have cloned with the --mirror flag, this is what it's supposed\n> to do: https://git-scm.com/docs/git-clone#git-clone---mirror\n> https://git-scm.com/docs/git-fetch#git-fetch---prune\n>\n> I.e. you push and git tries to mirror the refs you have locally to the\n> remote, including pruning stuff in the remote.\n\nThank you very much for diagnosing my issue.\nI was not aware about how --mirror affects the workflow.\nIt all makes perfect sense now.\n\nBest regards,\n-- \nMateusz Loskot, http://mateusz.loskot.net\n"}]}