When I try to push to a remote git branch to delete it with git push origin :branchname I get the following error message:
error: unable to push to unqualified destination: remotes/origin/branchname
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
But when I type git branch -a I still see it in remotes/origin/branchname. Why can’t I delete it remotely?
The branch has already been deleted in the origin repository. You can reflect this in your local remotes when you fetch by doing
git fetch --all --prune, which will delete it from your remotes. You can also more specifically dogit remote pruneto just prune your remotes without updating.