Why can't I delete a remote branch in BitBucket?

When I try to do git push origin :foo-branch', I get an error:

error: unable to delete 'foo-branch': remote ref does not exist
error: failed to push some refs to 'git@bitbucket.org:username/repo-name.git'

I know the branch exist, because:

  • I see it in git log --all;
  • I see it in the web interface on BitBucket

What’s more, even after I run git remote prune origin, I can still see it, when I run git branch -a:


I have also tried git fetch -p origin and still couldn’t solve this problem.

Git Baby is a git and github fan, let's start git clone.