{"thread":{"id":"63593","subject":"Git push tries to delete branch twice and fails","startedAt":"2025-06-06T11:20:42Z","lastAt":"2025-06-06T11:58:07Z","messageCount":4,"participants":["Ondra Medek","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"519839","messageId":"CAJsoDaFKRz8om1d4YPtaqdyuBuPAiC-xHDuvmYW=VQWEzzXAtg@mail.gmail.com","threadId":"63593","inReplyTo":null,"subject":"Git push tries to delete branch twice and fails","fromName":"Ondra Medek","fromEmail":"xmedeko@gmail.com","sentAt":"2025-06-06T11:20:30Z","receivedAt":"2025-06-06T11:20:42Z","isPatch":false,"sender":{"key":"xmedeko@gmail.com","avatar":"https://gravatar.com/avatar/09ec305680e81ade2e3617fd245cda7136f6d5e859b5120feb9436e0725f6e1d?d=mp&s=160"},"body":"I have a git 2.49.0 (Windows) and one local working tree is kind of\nbroken, when I try:\n\n$ git push origin branch1\nTotal 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)\nTo file:///c:/...\n * [new branch]            branch1 -> branch1\nEverything up-to-date\n\n$ git push origin :branch1\nTo file:///c:/...\n - [deleted]               branch1\nerror: unable to delete 'branch1': remote ref does not exist\nerror: failed to push some refs to 'file:///c:/...'\n\nSo, the same `git push` command first deletes the branch and then\nfails because it does not exist. It worked well until something\nhappened and since that time it's broken. I've tried `git gc\n--aggressive --prune`, but it didn't help.\n\nWhen I do `git clone` of the same repository to another local working\ntree, then it's OK - the branch is deleted without the error.\n\nIs this a Git bug? Is it possible to fix the local working tree except\nfor a new git clone?\n\nNote: I am developing an app which uses (creates and deletes) custom\nrefs often. So, I've hit this bug when trying to delete a custom ref.\nI have cleared all custom refs and tried that with Git branches.\n\nCheers\nAndy\n"},{"id":"519843","messageId":"ad141d46-3170-47d0-860d-46e7b92f878d@app.fastmail.com","threadId":"63593","inReplyTo":"CAJsoDaFKRz8om1d4YPtaqdyuBuPAiC-xHDuvmYW=VQWEzzXAtg@mail.gmail.com","subject":"Re: Git push tries to delete branch twice and fails","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-06-06T11:41:08Z","receivedAt":"2025-06-06T11:43:29Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Fri, Jun 6, 2025, at 13:20, Ondra Medek wrote:\n> I have a git 2.49.0 (Windows) and one local working tree is kind of\n> broken, when I try:\n>\n> $ git push origin branch1\n> Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)\n> To file:///c:/...\n>  * [new branch]            branch1 -> branch1\n> Everything up-to-date\n>\n> $ git push origin :branch1\n> To file:///c:/...\n>  - [deleted]               branch1\n> error: unable to delete 'branch1': remote ref does not exist\n> error: failed to push some refs to 'file:///c:/...'\n\nI was note able to reproduce on Git 2.49.0 on Linux.  Both through a\nHTTPS remote as well as a local (filesystem) remote.\n\n```\n$ ./git diagnose\nCollecting diagnostic info\n\ngit version 2.49.0\ncpu: x86_64\nbuilt from commit: 683c54c999c301c2cd6f715c411407c413b1d84e\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nlibcurl: 7.81.0\nOpenSSL: OpenSSL 3.0.2 15 Mar 2022\nzlib: 1.2.11\nRepository root: <path>\nAvailable space on '<path>': 202.28 GiB (mount flags 0x1000)\n```\n\n> So, the same `git push` command first deletes the branch and then\n> fails because it does not exist. It worked well until something\n> happened and since that time it's broken. I've tried `git gc\n> --aggressive --prune`, but it didn't help.\n>\n> When I do `git clone` of the same repository to another local working\n> tree, then it's OK - the branch is deleted without the error.\n>\n> Is this a Git bug? Is it possible to fix the local working tree except\n> for a new git clone?\n>\n> Note: I am developing an app which uses (creates and deletes) custom\n> refs often. So, I've hit this bug when trying to delete a custom ref.\n> I have cleared all custom refs and tried that with Git branches.\n>\n> Cheers\n> Andy\n"},{"id":"519844","messageId":"CAJsoDaGjF=2ZGwGdnx+M-1MdtfDWS2uE8+EAZMuu73cXjhWb7Q@mail.gmail.com","threadId":"63593","inReplyTo":"ad141d46-3170-47d0-860d-46e7b92f878d@app.fastmail.com","subject":"Re: Git push tries to delete branch twice and fails","fromName":"Ondra Medek","fromEmail":"xmedeko@gmail.com","sentAt":"2025-06-06T11:50:30Z","receivedAt":"2025-06-06T11:50:42Z","isPatch":false,"sender":{"key":"xmedeko@gmail.com","avatar":"https://gravatar.com/avatar/09ec305680e81ade2e3617fd245cda7136f6d5e859b5120feb9436e0725f6e1d?d=mp&s=160"},"body":"Yes, I have witten it's just in one local working tree. When I do `git\nclone` of the same repository then it's OK. So I do not know how to\nsimulate it.\n\nTherefore, the workaround is simple - I may just delete the local dir\nand clone the repo again. But I would like just to know what happened\nand if it's possible to fix it without cloning if the same issue hit\nsome of our customers.\n---\nAndy\n\nOn Fri, 6 Jun 2025 at 13:43, Kristoffer Haugsbakk\n<kristofferhaugsbakk@fastmail.com> wrote:\n>\n> On Fri, Jun 6, 2025, at 13:20, Ondra Medek wrote:\n> > I have a git 2.49.0 (Windows) and one local working tree is kind of\n> > broken, when I try:\n> >\n> > $ git push origin branch1\n> > Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)\n> > To file:///c:/...\n> >  * [new branch]            branch1 -> branch1\n> > Everything up-to-date\n> >\n> > $ git push origin :branch1\n> > To file:///c:/...\n> >  - [deleted]               branch1\n> > error: unable to delete 'branch1': remote ref does not exist\n> > error: failed to push some refs to 'file:///c:/...'\n>\n> I was note able to reproduce on Git 2.49.0 on Linux.  Both through a\n> HTTPS remote as well as a local (filesystem) remote.\n>\n> ```\n> $ ./git diagnose\n> Collecting diagnostic info\n>\n> git version 2.49.0\n> cpu: x86_64\n> built from commit: 683c54c999c301c2cd6f715c411407c413b1d84e\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> libcurl: 7.81.0\n> OpenSSL: OpenSSL 3.0.2 15 Mar 2022\n> zlib: 1.2.11\n> Repository root: <path>\n> Available space on '<path>': 202.28 GiB (mount flags 0x1000)\n> ```\n>\n> > So, the same `git push` command first deletes the branch and then\n> > fails because it does not exist. It worked well until something\n> > happened and since that time it's broken. I've tried `git gc\n> > --aggressive --prune`, but it didn't help.\n> >\n> > When I do `git clone` of the same repository to another local working\n> > tree, then it's OK - the branch is deleted without the error.\n> >\n> > Is this a Git bug? Is it possible to fix the local working tree except\n> > for a new git clone?\n> >\n> > Note: I am developing an app which uses (creates and deletes) custom\n> > refs often. So, I've hit this bug when trying to delete a custom ref.\n> > I have cleared all custom refs and tried that with Git branches.\n> >\n> > Cheers\n> > Andy\n"},{"id":"519845","messageId":"CAJsoDaHQnwJTnWDT3eeTsH-nC9Tbt019T4W0pocqBSH80_FYqg@mail.gmail.com","threadId":"63593","inReplyTo":"CAJsoDaGjF=2ZGwGdnx+M-1MdtfDWS2uE8+EAZMuu73cXjhWb7Q@mail.gmail.com","subject":"Re: Git push tries to delete branch twice and fails","fromName":"Ondra Medek","fromEmail":"xmedeko@gmail.com","sentAt":"2025-06-06T11:57:55Z","receivedAt":"2025-06-06T11:58:07Z","isPatch":false,"sender":{"key":"xmedeko@gmail.com","avatar":"https://gravatar.com/avatar/09ec305680e81ade2e3617fd245cda7136f6d5e859b5120feb9436e0725f6e1d?d=mp&s=160"},"body":"Ah, got it, I have in .git/config the same path twice (I did it\nunintentionally by manual edit):\n\n[remote \"origin\"]\n    url = file:///c:/...\n    url = file:///c:/...\n    fetch = +refs/heads/*:refs/remotes/origin/*\n\nSorry for bothering you\nAndy\n\nOn Fri, 6 Jun 2025 at 13:50, Ondra Medek <xmedeko@gmail.com> wrote:\n>\n> Yes, I have witten it's just in one local working tree. When I do `git\n> clone` of the same repository then it's OK. So I do not know how to\n> simulate it.\n>\n> Therefore, the workaround is simple - I may just delete the local dir\n> and clone the repo again. But I would like just to know what happened\n> and if it's possible to fix it without cloning if the same issue hit\n> some of our customers.\n> ---\n> Andy\n>\n> On Fri, 6 Jun 2025 at 13:43, Kristoffer Haugsbakk\n> <kristofferhaugsbakk@fastmail.com> wrote:\n> >\n> > On Fri, Jun 6, 2025, at 13:20, Ondra Medek wrote:\n> > > I have a git 2.49.0 (Windows) and one local working tree is kind of\n> > > broken, when I try:\n> > >\n> > > $ git push origin branch1\n> > > Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)\n> > > To file:///c:/...\n> > >  * [new branch]            branch1 -> branch1\n> > > Everything up-to-date\n> > >\n> > > $ git push origin :branch1\n> > > To file:///c:/...\n> > >  - [deleted]               branch1\n> > > error: unable to delete 'branch1': remote ref does not exist\n> > > error: failed to push some refs to 'file:///c:/...'\n> >\n> > I was note able to reproduce on Git 2.49.0 on Linux.  Both through a\n> > HTTPS remote as well as a local (filesystem) remote.\n> >\n> > ```\n> > $ ./git diagnose\n> > Collecting diagnostic info\n> >\n> > git version 2.49.0\n> > cpu: x86_64\n> > built from commit: 683c54c999c301c2cd6f715c411407c413b1d84e\n> > sizeof-long: 8\n> > sizeof-size_t: 8\n> > shell-path: /bin/sh\n> > libcurl: 7.81.0\n> > OpenSSL: OpenSSL 3.0.2 15 Mar 2022\n> > zlib: 1.2.11\n> > Repository root: <path>\n> > Available space on '<path>': 202.28 GiB (mount flags 0x1000)\n> > ```\n> >\n> > > So, the same `git push` command first deletes the branch and then\n> > > fails because it does not exist. It worked well until something\n> > > happened and since that time it's broken. I've tried `git gc\n> > > --aggressive --prune`, but it didn't help.\n> > >\n> > > When I do `git clone` of the same repository to another local working\n> > > tree, then it's OK - the branch is deleted without the error.\n> > >\n> > > Is this a Git bug? Is it possible to fix the local working tree except\n> > > for a new git clone?\n> > >\n> > > Note: I am developing an app which uses (creates and deletes) custom\n> > > refs often. So, I've hit this bug when trying to delete a custom ref.\n> > > I have cleared all custom refs and tried that with Git branches.\n> > >\n> > > Cheers\n> > > Andy\n"}]}