Git push tries to delete branch twice and fails
- From
Ondra Medek <xmedeko@gmail.com>
- Date
- Jun 6, 2025, 11:20 UTC
- Message-ID
- <CAJsoDaFKRz8om1d4YPtaqdyuBuPAiC-xHDuvmYW=VQWEzzXAtg@mail.gmail.com>
I have a git 2.49.0 (Windows) and one local working tree is kind of broken, when I try:
$ git push origin branch1 Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) To file:///c:/... * [new branch] branch1 -> branch1 Everything up-to-date
$ git push origin :branch1 To file:///c:/... - [deleted] branch1 error: unable to delete 'branch1': remote ref does not exist error: failed to push some refs to 'file:///c:/...'
So, the same `git push` command first deletes the branch and then fails because it does not exist. It worked well until something happened and since that time it's broken. I've tried `git gc --aggressive --prune`, but it didn't help.
When I do `git clone` of the same repository to another local working tree, then it's OK - the branch is deleted without the error.
Is this a Git bug? Is it possible to fix the local working tree except for a new git clone?
Note: I am developing an app which uses (creates and deletes) custom refs often. So, I've hit this bug when trying to delete a custom ref. I have cleared all custom refs and tried that with Git branches.
Cheers Andy