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

Re: Simple git push --tags deleted all branches

From
Mateusz Loskot <mateusz@loskot.net>
Date
Nov 29, 2018, 15:18 UTC
Message-ID
<CABUeae_VVtbj0JCRyUuqf=uaPFXkmHwHpYyapH4H5A_cQSQsdA@mail.gmail.com>
In-Reply-To
<87y39cx6wt.fsf@evledraar.gmail.com>
On Thu, 29 Nov 2018 at 16:03, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 51 quoted lines
> On Wed, Nov 28 2018, Mateusz Loskot wrote:
> >
> > (using git version 2.19.2.windows.1)
> >
> > I've just encountered one of those WTH moments.
> >
> > I have a bare repository
> >
> > core.git (BARE:master) $ git branch
> >   1.0
> >   2.0
> > * master
> >
> > core.git (BARE:master) $ git tag
> > 1.0.1651
> > 1.0.766
> > 2.0.1103
> > 2.0.1200
> >
> > I published the repo using: git push --all --follow-tags
> >
> > This succeeded, but there seem to be no tags pushed, just branches.
> > So, I followed with
> >
> > core.git (BARE:master) $ git push --tags
> > To XXX
> >  - [deleted]               1.0
> >  - [deleted]               2.0
> >  ! [remote rejected]       master (refusing to delete the current
> > branch: refs/heads/master)
> > error: failed to push some refs to 'XXX'
> >
> > And, I've found out that all branches and tags have been
> > wiped in both, local repo and remote :)
> >
> > I restored the repo and tried out
> >
> > git push origin 1.0
> > git push origin --tags
> >
> > and this time both succeeded, without wiping out any refs.
> >
> > Could anyone help me to understand why remote-less
> >
> > git push --tags
> >
> > is/was so dangerous and unforgiving?!
>
> Since nobody's replied yet, I can't see what's going on here from the
> info you've provided. My guess is that you have something "mirror" set
> on the remote.
Thank you for responding.

The git push --tags hugely surprised me, and here is genuine screenshot https://twitter.com/mloskot/status/1068072285846859776

> It seems you can't share the repo or its URL, but could you share the
> scrubbed output of 'git config -l --show-origin' when run inside this
> repository?

Here is complete output. I have not stripped the basics like aliases, just in case.

```
core-external-metadata.git (BARE:master) $ git config -l --show-origin
file:"C:\\ProgramData/Git/config"       core.symlinks=false
file:"C:\\ProgramData/Git/config"       core.autocrlf=true
file:"C:\\ProgramData/Git/config"       color.diff=auto
file:"C:\\ProgramData/Git/config"       color.status=auto
file:"C:\\ProgramData/Git/config"       color.branch=auto
file:"C:\\ProgramData/Git/config"       color.interactive=true
file:"C:\\ProgramData/Git/config"       help.format=html
file:"C:\\ProgramData/Git/config"       http.sslcainfo=C:/Program
Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:"C:\\ProgramData/Git/config"       diff.astextplain.textconv=astextplain
file:"C:\\ProgramData/Git/config"       rebase.autosquash=true
file:C:/Program Files/Git/mingw64/etc/gitconfig
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:C:/Program Files/Git/mingw64/etc/gitconfig http.sslbackend=openssl
file:C:/Program Files/Git/mingw64/etc/gitconfig
diff.astextplain.textconv=astextplain
file:C:/Program Files/Git/mingw64/etc/gitconfig
filter.lfs.clean=git-lfs clean -- %f
file:C:/Program Files/Git/mingw64/etc/gitconfig
filter.lfs.smudge=git-lfs smudge -- %f
file:C:/Program Files/Git/mingw64/etc/gitconfig
filter.lfs.process=git-lfs filter-process
file:C:/Program Files/Git/mingw64/etc/gitconfig filter.lfs.required=true
file:C:/Program Files/Git/mingw64/etc/gitconfig credential.helper=manager
file:C:/Users/mateuszl/.gitconfig       user.name=Mateusz Łoskot
file:C:/Users/mateuszl/.gitconfig       user.email=mateusz@loskot.net
file:C:/Users/mateuszl/.gitconfig       github.user=mloskot
file:C:/Users/mateuszl/.gitconfig       core.editor=vim
file:C:/Users/mateuszl/.gitconfig       color.branch=auto
file:C:/Users/mateuszl/.gitconfig       color.diff=auto
file:C:/Users/mateuszl/.gitconfig       color.status=auto
file:C:/Users/mateuszl/.gitconfig       color.ui=auto
file:C:/Users/mateuszl/.gitconfig       alias.br=branch
file:C:/Users/mateuszl/.gitconfig       alias.bv=branch -vv
file:C:/Users/mateuszl/.gitconfig       alias.brv=branch -vv
file:C:/Users/mateuszl/.gitconfig       alias.bra=branch -a
file:C:/Users/mateuszl/.gitconfig       alias.ci=commit --verbose
file:C:/Users/mateuszl/.gitconfig       alias.cia=commit --verbose --amend
file:C:/Users/mateuszl/.gitconfig       alias.ciae=commit --verbose
--amend --no-edit
file:C:/Users/mateuszl/.gitconfig       alias.co=checkout
file:C:/Users/mateuszl/.gitconfig       alias.dc=diff --cached
file:C:/Users/mateuszl/.gitconfig       alias.df=diff
file:C:/Users/mateuszl/.gitconfig       alias.gf=flow
file:C:/Users/mateuszl/.gitconfig       alias.lg=log --color --graph
--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)
%C(bold blue)<%an>%Creset' --abbrev-commit
file:C:/Users/mateuszl/.gitconfig       alias.lol=log --graph
--decorate --pretty=oneline --abbrev-commit
file:C:/Users/mateuszl/.gitconfig       alias.lola=log --graph
--decorate --pretty=oneline --abbrev-commit --all
file:C:/Users/mateuszl/.gitconfig       alias.ls=ls-files
file:C:/Users/mateuszl/.gitconfig       alias.lst=lfs status
file:C:/Users/mateuszl/.gitconfig       alias.rt=remote
file:C:/Users/mateuszl/.gitconfig       alias.rtv=remote -v
file:C:/Users/mateuszl/.gitconfig       alias.st=status
file:C:/Users/mateuszl/.gitconfig       alias.ghclm=!sh -c 'git log
$1...$2  --pretty=format:"* [view](http://github.com/$3/$4/commit/%H)
- %s"' -
file:C:/Users/mateuszl/.gitconfig       alias.ign=ls-files -o -i
--exclude-standard
file:C:/Users/mateuszl/.gitconfig
alias.prune-branches-origin=!git remote prune origin && git branch -vv
| grep ': gone]' | awk '{print $1}' | xargs -r git branch -D
file:C:/Users/mateuszl/.gitconfig
alias.prune-branches-mloskot=!git remote prune mloskot && git branch
-vv | grep ': gone]' | awk '{print $1}' | xargs -r git branch -D
file:C:/Users/mateuszl/.gitconfig       alias.hist=log
--pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
file:C:/Users/mateuszl/.gitconfig       commit.template=~/.gitmessage
file:C:/Users/mateuszl/.gitconfig       credential.helper=manager
file:C:/Users/mateuszl/.gitconfig       filter.lfs.clean=git-lfs clean -- %f
file:C:/Users/mateuszl/.gitconfig       filter.lfs.smudge=git-lfs
smudge --skip -- %f
file:C:/Users/mateuszl/.gitconfig       filter.lfs.process=git-lfs
filter-process --skip
file:C:/Users/mateuszl/.gitconfig       filter.lfs.required=true
file:config     core.repositoryformatversion=0
file:config     core.filemode=false
file:config     core.bare=true
file:config     core.symlinks=false
file:config     core.ignorecase=true
file:config     remote.origin.url=https://xxx.com/core-external-metadata.git
file:config     remote.origin.fetch=+refs/*:refs/*
file:config     remote.origin.mirror=true
file:config
lfs.https://xxx.com/core-external-metadata.git/info/lfs.access=basic
```
Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 4 of 6 in “Simple git push --tags deleted all branches”
  1. Mateusz LoskotNov 28, 2018
  2. Mateusz LoskotNov 28, 2018
  3. Ævar Arnfjörð BjarmasonNov 29, 2018
  4. Mateusz LoskotNov 29, 2018
  5. Ævar Arnfjörð BjarmasonNov 29, 2018
  6. Mateusz LoskotDec 4, 2018

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.