如何删除已经从远程删除的分支

How to delete a branch which is already deleted from remote

我与其他开发人员一起开发一个项目,其中有一个 Github 存储库。我们创建了一个分支,然后在完成工作后,我们删除了 Github 上的分支。但是在我的本地回购协议中,我又有了分支(我在调用 git branch --list -a 时看到了它)。它是一个远程分支,但它不再存在于远程仓库中。

我尝试使用 git branch -d remotes/origin/<branch>(也使用 -D 但这不是问题所在)。 Git 回答“错误:分支 'remotes/origin/morgan-save-A' 非 trouvee”。

如果有人有想法,我该如何删除它?感谢阅读:)

git fetch --prune

来自the docs

Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning. Supplying --prune-tags is a shorthand for providing the tag refspec.