删除远程分支的尝试失败 :
$ 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 分支 - D 分支 - D 分支_ to_ deletete , 如果它没有完全合并到其它分支中, 比如 。
git checkout some_other_branch
git push origin :branch_to_delete
git branch -d branch_to_delete
如果您删除了远程分支, 不需要远程剪切。 它只用来获取您正在跟踪的仓库中可用的最新远程 。 我观察过 Git 抓取将会添加远程, 而不是移除它们 。 下面的例子说明 Git 远程 Pinene 何时会真正做点什么 :
用户 A 执行上述步骤。 用户 B 将运行以下命令以查看最新的远程分支 :
git fetch
git remote prune origin
git branch -r
使用 Git Bash 您可以执行以下操作 :
git branch --delete <branch>
或
- 带
从 GitHub 桌面应用程序中, 当您检查了分支时, 您可以通过分支菜单条删除本地分支 :
调
如果您没有使用 GitHub 桌面应用程序, 并且正在使用像视觉工作室那样的 IDE 来控制本地源码, 您只需要采取几个快速步骤 :
检查您要删除的分支以外的分支。右键单击您想要删除的分支。从上下文菜单中选择删除选项。
然后,一旦在网上登录到您的 GitHub 账户, 转到仓库, 并单击所有分支的标签。 从那里, 单击小垃圾桶就可以在右侧您想要删除的分支的名称上图标 。
调
无需试图从你的网上存储库删除。
删除本地端 - (正常)
git branch -d my_branch
如果分行处于调整/合并的进度中,且未正确完成,这意味着您将会出错, 重设/ 计量在进行中, 因此在这种情况下, 您将无法删除分行 。
所以要么你需要解决重置/合并问题。 否则,你可以通过使用, 强制删除,
git branch -D my_branch
要删除远程 :
git push --delete origin my_branch
您可以使用 :
git push origin :my_branch # Easy to remember both will do the same.
图形代表:
调
提示:当您使用删除分支时
git branch -d <branchname> # Deletes local branch
或
git push origin :<branchname> # Deletes remote branch
仅删除引用 。 即使该分支实际上被远程删除, 但它的引用仍然存在于您的团队成员所在的本地存储库中 。 这意味着对于其他团队成员来说, 被删除的分支在做 Git 分支 - a 时仍然可见 。
为了解决这个问题,你的团队成员可以使用
git remote prune <repository>
这是典型的 Git 远程纯素来源 。