Q . git delete remote branch not working: branch not found.

Parvathi Devi. asked, Jun 25 ' 2016

I am trying to delete a remote branch but it is giving error : branch not found, 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?

  • git
  • git-branch
  • git-delete

1 Answers

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

Leave a Ansewer