删除远程分支的尝试失败 :

$ 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.

我如何正确删除本地和远程的远程/原产/bugfix分支?


当前回答

如果您想要删除分支, 请先向要删除的分支以外的分支首选 。

git checkout other_than_branch_to_be_deleted

删除本地分支 :

git branch -D branch_to_be_deleted

删除远程分支 :

git push origin --delete branch_to_be_deleted

其他回答

提示:当您使用删除分支时

git branch -d <branchname> # Deletes local branch

git push origin :<branchname> # Deletes remote branch

仅删除引用 。 即使该分支实际上被远程删除, 但它的引用仍然存在于您的团队成员所在的本地存储库中 。 这意味着对于其他团队成员来说, 被删除的分支在做 Git 分支 - a 时仍然可见 。

为了解决这个问题,你的团队成员可以使用

git remote prune <repository>

这是典型的 Git 远程纯素来源 。

删除远程分支的命令行的替代选项是 GitHub 分支页面。

例如,见:https://github.com/agorm/agorgon.js/branches。

在代码 - > GitHub 库的分支页面中找到 。

我一般更喜欢指挥行本身,但这个 GitHub 页面显示您对分支的更多信息,例如最新日期和用户,以及前后承诺的数量。 这对于处理大量分支很有用。

删除远程分支

git 推推源 : <branchname>

删除本地分支

git 分支 -D <branchname>

删除本地分支步骤 :

退出退出到另一个分支删除本地分支

除了其他答案之外, 我经常使用 git_ remote_ branch 工具。 这是一个额外的安装, 但是它能方便地与远程分支进行互动。 在这种情况下, 请删除 :

grb delete branch

我发现我还经常使用 出版和跟踪命令。

git push origin --delete <branch Name>

较容易记住

git push origin :branchName