git branch -a
显示
master
remotes/origin/master
remotes/upstream/bugfix/corrupted-deb
... (many more remotes/upstream branches)
存储库upstream
不再存在。如何永久删除僵尸分支remotes/upstream/bugfix/corrupted-deb
等?
文件.git/config
所包含的内容不超过
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@<myurl>
fetch = +refs/heads/*:refs/remotes/origin/*
很久以来,对upstream
的任何有意引用都消失了。
命令git remote prune origin
[https://stackoverflow.com/questions/8766525]不影响upstream
。明显的变体git remote prune upstream
导致fatal: 'upstream' does not appear to be a git repository ...
答案 0 :(得分:2)
尝试:
git update-ref -d refs/remotes/upstream/bugfix/corrupted-deb
有时候您可能会有一个符号引用,例如:
remotes/origin/HEAD -> origin/master
要删除remotes/origin/HEAD
,请运行:
git symbolic-ref -d refs/remotes/origin/HEAD
要删除所有remotes/upstream
,请尝试:
git for-each-ref refs/remotes/upstream --format="%(refname)" | while read ref;do
git update-ref -d ${ref}
done
答案 1 :(得分:1)
git branches -a
只是告诉您.git
文件夹中的本地文件(有时是通过git fetch
创建的)。只需将其删除:
.git/refs/remotes/upstream/bugfix/corrupted-deb
举例来说,我创建了一个小型测试项目,并手动创建了一个文件.git/refs/remotes/test/feature/mybranch
,该文件指向我所做的单次提交的内容。
运行git branch -a
现在会产生:
/c/dev/remotetest (master)
$ git branch -a
* master
remotes/test/feature/mybranch
在删除运行.git/refs/remotes/test/feature/mybranch
的文件git branch -a
之后,现在显示:
/c/dev/remotetest (master)
$ git branch -a
* master
/马丁