You can just push empty to delete remote branch (note the nothing before ":"):

git push origin :branch_name

The normal push is equivalent to (your current HEAD is branched from remote "branch_name")

git push origin HEAD:branch_name






On Saturday, 17 December 2022 at 05:51:25 GMT+8, Gerald Pfeifer <[email protected]> wrote:


On Tue, 13 Dec 2022, Gerald Pfeifer wrote:
> https://wiki.winehq.org/Git_Wine_Tutorial#Deleting_branches has
>
>  Deleting branches
>
>  git branch -D new-branch
>
> Alas that does not work for me.
>
>  % git branch -a
>  * master
>    remotes/origin/HEAD -> origin/master
>    remotes/origin/dll_soinit.c-stddef.h
:
>
>  % git branch -D dll_soinit.c-stddef.h
>  error: branch 'dll_soinit.c-stddef.h' not found.

I believe I can now answer my own question, having dug into it a bit.

The invocation above is for *local* branches, branches in the local
checkout.

To remove a *remote* branch, for example where a merge request was not
accepted or was "bad" for some reason, we need to use `git push` instead
of `git branch`:

  % git push origin --delete dll_soinit.c-stddef.h

I plan on adding this to the Wiki in a few days.
Any suggestions/concerns?

Gerald