删除远程分支的尝试失败 :
$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found.
$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found.
$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).
$ git push
Everything up-to-date
$ git pull
From github.com:gituser/gitproject
* [new branch] bugfix -> origin/bugfix
Already up-to-date.
我如何正确删除remotes/origin/bugfix
本地和远程分支?
使用吉特巴什您可以执行以下操作:
git branch --delete <branch>
或
-
从 GitHub 桌面应用程序中删除当地当地通过分支通过分处菜单条 :

如果你(如果)不属于使用 GitHub 桌面应用程序, 并正在使用像视觉工作室那样的 IDE 来控制本地源码, 您只需要快速的一步 :
- 检查您要删除的分支以外的分支 。
- 右键单击您想要删除的分支 。
- 选择删除删除删除从上下文菜单中选择。
然后,一旦登录到您的 GitHub 账户, 一旦登录到您的 GitHub 在线账户, 转到存储库并单击所有各处选项卡。从此选项卡中,单击您想要删除的分支名称右侧的小垃圾桶图标。

无需试图从你的网上存储库删除。
许多其他答案都会导致错误/警告。git branch -D branch_to_delete
如果未完全合并到some_other_branch
例如。
git checkout some_other_branch
git push origin :branch_to_delete
git branch -d branch_to_delete
如果您删除了远程分支, 不需要远程剪切。 它只用来获取您正在跟踪的仓库中可用的最新的远程 。 我观察到了git fetch
添加遥控器, 而不是删除它们。 这里举例说明何时git remote prune origin
将实际做一些事情:
用户 A 执行上述步骤。 用户 B 将运行以下命令以查看最新的远程分支 :
git fetch
git remote prune origin
git branch -r