git delete remote branch not working: branch not found
Solution 1
According to this post:
Deleting is also a pretty simple task (despite it feeling a bit kludgy):
git push origin :newfeature
That will delete the newfeature branch on the origin remote, but you’ll still need to delete the branch locally with git branch -d newfeature.
So the error you got just means you don't have a local copy of that branch, so you can ignore it. Then to delete the remote copy:
git push origin :branch_to_delete
Solution 2
If you couldn't see it on the server (which is my case, because someone has already deleted that branch on the remote server) but it's still present in your local .git
repository as the remote branch, you would be able to fix the issue with nor git push origin --delete [branch]
neither with git push origin :branch_to_delete
. Instead run the
git branch --all
git remote prune origin
git branch --all
replacing the origin
with the name of your remote.
Solution 3
To delete a remote branch, the command is:
$ git push origin --delete [branch]
It looks like someone forgot the '--delete' in one of the earlier answers.
Related videos on Youtube

doniyor
Python Developer, Django Developer, Fullstack. Ideas. World. Changes. Trace.
Updated on June 24, 2022Comments
-
doniyor 6 months
I am trying to delete a remote branch in git, I did:
git branch -r ... origin/master origin/dev origin/branch_to_delete
now I try to delete
origin/branch_to_delete
:git branch -d origin/branch_to_delete error: branch 'origin/branch_to_delete' not found
I did:
git fetch --all
and tried again, the same error. I tried with
-D
but the same error.but the branch is there, I can see it in github.com. What to do?
-
doniyor over 7 yearsthanks. it is so dumb, I thought this will work only if the first step works, but obviously first step was somehow already done.. thanks it worked
-
Wrokar over 3 yearsWhile you can use the
--delete
option, the other answer includes a:
in front of the branch name which will delete the remote branch. -
ieXcept over 2 yearsnot working. Proofs: error: unable to delete 'github_hub/dev': remote ref does not exist
-
ieXcept over 2 yearserror: unable to delete 'github_hub/dev': remote ref does not exist