简体   繁体   English

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

[英]Why can't I delete a remote git branch with git push origin :branchname?

When I try to push to a remote git branch to delete it with git push origin:branchname I get the following error message:当我尝试推送到远程 git 分支以使用git push origin:branchname删除它时,我收到以下错误消息:

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.错误:无法推送到不合格的目标:remote/origin/branchname 目标 refspec 既不匹配远程上的现有 ref,也不以 refs/ 开头,我们无法根据源 ref 猜测前缀。

But when I type git branch -a I still see it in remotes/origin/branchname .但是当我输入git branch -a时,我仍然在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.当您通过执行git fetch --all --prune时,您可以在本地遥控器中反映这一点,这将从您的遥控器中删除它。 You can also more specifically do git remote prune to just prune your remotes without updating.您还可以更具体地执行git remote prune以仅修剪您的遥控器而不进行更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM