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

$ 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/packed ref中的条目。您可以编辑此纯文本文件,并删除git br-D不知道如何触摸的条目(至少在1.7.9.5版本中)。

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

其他回答

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

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

我不知道git branch-rd,所以我自己解决此类问题的方法是将我的回购视为远程回购并进行远程删除。git push.:refs/remotes/public/master。如果其他方法不起作用,并且你想删除一些奇怪的引用,那么这种生涩的方法一定会奏效。它使您能够精确地删除(或创建!)任何类型的引用。

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

你需要做的就是

git fetch -p

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

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

git config fetch.prune true

or

git config --global fetch.prune true

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

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