在我当前的 repo 中,我有以下输出:
$ 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.
此外,git remote
的输出很奇怪,因为它没有列出 public
:
$ git remote show
origin
如何从分支列表中删除“remotes/public/master”?
更新,尝试了git push
命令:
$ git push public :master
fatal: 'public' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
最佳答案
您可能需要清理:
git gc --prune=now
或者您可能需要修剪:
git remote prune public
prune
Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>".
With --dry-run option, report what branches will be pruned, but do no actually prune them.
但是,看起来这些应该早点用
清理掉git remote rm public
rm
Remove the remote named <name>. All remote tracking branches and configuration settings for the remote are removed.
所以可能是您手动编辑了您的配置文件而这并没有发生,或者您有权限问题。
也许再运行一次,看看会发生什么。
建议背景
如果您查看 revision logs ,你会注意到我建议了更多“正确”的技术,无论出于何种原因不想在他们的存储库上工作。
我怀疑 OP 做了一些让他们的树处于不一致状态的事情,导致它的行为有点奇怪,并且需要 git gc
来修复遗留的 cruft。
通常 git branch -rd origin/badbranch
足以破坏本地跟踪分支,或 git push origin :badbranch
破坏一个远程分支,通常您从不需要调用git gc
关于git - 如何从 Git 中删除无效的远程分支引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1072171/