我运行git branch -a

* master
  remotes/origin/test
  remotes/origin/master

我想删除我的远程分支

我试过了

git push origin --delete remotes/origin/test

我得到了

错误:无法删除'remotes/origin/test':远程引用不 存在

怎么会不存在呢?

我做了一个git分支-a,我看到它列出来了。

我错过什么了吗?


当前回答

对我来说,这是有效的$▶git branch -D -r origin/mybranch

细节

$ ▶ git 分支 -a |格雷普·米布兰奇 远程/源/我的分支

$ ▶ git 分支 -r |格雷普·米布兰奇 原产地/我的分支

$▶git分支 开发 *功能/用于

▶git push origin——删除mybranch 错误:无法删除'mybranch': remote ref不存在 错误:无法将一些引用推到'git@10.102.100.38:config/myrepo.git'

▶git branch -D -r origin/mybranch 删除远程分支来源/mybranch (was 62c7421)。

$ ▶ git 分支 -a |格雷普·米布兰奇

$ ▶ git 分支 -r |格雷普·米布兰奇

其他回答

假设远程分支是remotes/origin/test,你可以使用两种方法:

git push origin --delete test

and

git branch -D -r origin/test
git push origin --delete origin/test 

应该也可以

对于windows

git branch --remotes| %{ $_.Trim().Split("/")[1] }| ?{ $_ -ne 'master' } | | ?{ $_ -ne 'otherBranch' } | %{ git push origin --delete $_ }

一个方便的单行程序,从原点删除'master'以外的分支:

git branch --remotes | grep -v 'origin/master' | sed "s/origin\///" | xargs -i{foo} git push origin --delete {foo}

在这样做之前,请确保您了解运行该程序的含义!

有一个快捷方式可以在原点中删除分支:

Git push origin:<branch_name>

这和git push origin——delete <branch_name>是一样的