为什么我无法使用git push origin :branchname删除远程git分支?

16
当我尝试使用git push origin :branchname来删除远程git分支时,出现以下错误信息:

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.

但是,当我键入git branch -a时,仍然可以看到它在remotes/origin/branchname中。为什么我不能在远程上删除它呢?
1个回答

23

该分支已被删除在远程仓库中。您可以通过执行git fetch --all --prune 反映到本地远程,这将从远程删除它。您也可以更具体地执行git remote prune来只修剪您的远程而不更新。


1
实际上,即使你知道答案或者可以快速找到答案,询问问题也是可以接受的,特别是如果在这里提供答案对于其他正在寻找答案的人有用的话。我没有看到这个问题的重复出现在任何地方,尽管我承认我没有很努力地搜索。 :-) - ebneter

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接