在我的当前回购中,我有以下输出:

$ git branch -a
* master
  remotes/origin/master
  remotes/public/master

我想从分支列表中删除remotes/public/master:

$ git branch -d remotes/public/master
error: branch 'remotes/public/master' not found.

此外,gitremote的输出很奇怪,因为它没有列出public:

$ git remote show 
origin

如何从分支列表中删除“remotes/public/master”?

更新,尝试了gitpush命令:

$ git push public :master
fatal: 'public' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

当前回答

当裁判被打包时,接受的答案对我不起作用。然而,这确实:

$ git remote add public http://anything.com/bogus.git
$ git remote rm public

其他回答

git push public :master

这将删除Kent Fredric指出的名为master的远程分支。

要列出远程跟踪分支,请执行以下操作:

git branch -r

要删除远程跟踪分支,请执行以下操作:

git branch -rd public/master

当裁判被打包时,接受的答案对我不起作用。然而,这确实:

$ git remote add public http://anything.com/bogus.git
$ git remote rm public

你需要做的就是

$ git branch -rd origin/whatever 

就这么简单。这里没有理由调用gc。

你需要做的就是

git fetch -p

它将删除所有远程删除的本地分支。

如果您使用的是git1.8.5+,则可以自动设置

git config fetch.prune true

or

git config --global fetch.prune true

不确定我是如何陷入混乱的,但我的错误消息略有不同:

>git远程>git分支警告:忽略中断的ref refs/remotes/origin/HEAD*主>

但我能够通过稍微重新解释本页其他地方的修复程序来修复它。我的意思是我用关键字HEAD替换了<remote>/<branch>中的分支名称。人们提到的其他建议都没有奏效(gc、prune等),所以我已经没有什么想法了,希望得到最好的结果。总之,它就像一个魅力:

>gitremote>gitbranch-rd-origin/HEAD删除了远程跟踪分支原点/HEAD(为refs/remotes/origin/main)。>git分支*main>