Git delete remote branch not working: branch not found

I am trying to remove a remote branch in git, I did:

git branch -r ... origin/master origin/dev origin/branch_to_delete 

now i am trying to remove 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 with the same error.

but there is a branch, I see it on github.com. What to do?

+11
git git-branch github
source share
2 answers

According to this post :

Removing is also a fairly simple task (even though it looks a bit like kludgy):

git push origin :newfeature

This will delete the newfeature branch on the source pool, but you still need to delete the branch locally using git branch -d newfeature.

Thus, the error you received simply means that you do not have a local copy of this branch, so you can ignore it. Then delete the remote copy:

 git push origin :branch_to_delete 
+15
source share

To delete a remote branch, enter the command:

$ git push origin --delete [branch]

It looks like someone forgot "--delete" in one of the previous answers.

+1
source share

All Articles