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

$ 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 push origin --delete <branch name>

引用自:http://www.gitguys.com/topics/adding-and-removing-remote-branches/

其他回答

我在这里尝试了一切,但都没有成功。如果所有其他操作都失败,请从文本文件“.git/packed refs”中删除有问题的分支,然后从“.git\refs\remotes\origin<branchName>”中删除问题的分支

我也有类似的问题。这些答案都没有帮助。在我的案例中,有两个已删除的远程存储库永久显示。

我的最后一个想法是手动删除所有对它的引用。

假设存储库名为“Repo”。我做到了:

find .git -name Repo 

因此,我从.git文件夹中删除了相应的文件和目录(这个文件夹可以在Rails应用程序或计算机上找到https://stackoverflow.com/a/19538763/6638513).

然后我做了:

grep Repo -r .git

这找到了一些文本文件,我在其中删除了相应的行。现在,一切似乎都很好。

通常,你应该把这份工作交给吉特。

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

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

gitgc--prune=now不是您想要的。

git remote prune public

或git remote prune origin#如果这是远程源

是你想要的

在我的例子中,我试图删除保存在.git/packed ref中的条目。您可以编辑此纯文本文件,并删除git br-D不知道如何触摸的条目(至少在1.7.9.5版本中)。

我在这里找到了这个解决方案:https://stackoverflow.com/a/11050880/1695680