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

$ 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

当前回答

仅略微相关,但在与我们相同的情况下可能仍然有用——我们使用网络文件共享作为远程存储库。上周一切正常,本周我们收到错误“远程源没有为分支Ref/heads/master发布Ref。此Ref可能不存在于远程中,或者可能被权限设置隐藏”

但我们认为没有采取任何措施来腐败。NFS做快照,所以我查看了每个“以前的版本”,发现三天前,存储库的MB大小已从282MB变为33MB,现在有大约1403个新文件和300个文件夹。我询问了我的同事,其中一人当天试图推送,然后取消了推送。

我使用NFS“恢复”功能将其恢复到该日期之前,现在一切都恢复正常。我以前确实试过修剪,但似乎没用。也许更严厉的清理会奏效。

希望有一天这会对其他人有所帮助!

Jay

其他回答

git push origin --delete <branch name>

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

你需要做的就是

git fetch -p

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

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

git config fetch.prune true

or

git config --global fetch.prune true

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

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

git remote prune public

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

是你想要的

你需要做的就是

$ git branch -rd origin/whatever 

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