git branch -a
shows
master
remotes/origin/master
remotes/upstream/bugfix/corrupted-deb
... (many more remotes/upstream branches)
The repository upstream
no longer exists. How to delete the zombie branches remotes/upstream/bugfix/corrupted-deb
etc for good?
File .git/config
contains no more than
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@<myurl>
fetch = +refs/heads/*:refs/remotes/origin/*
Any intentional reference to upstream
is gone since long.
The command git remote prune origin
[ https://stackoverflow.com/questions/8766525] doesn't affect upstream
. The obvious variant git remote prune upstream
results in fatal: 'upstream' does not appear to be a git repository...
Try:
git update-ref -d refs/remotes/upstream/bugfix/corrupted-deb
Sometimes you may have a symbolic ref like:
remotes/origin/HEAD -> origin/master
To remove remotes/origin/HEAD
, run:
git symbolic-ref -d refs/remotes/origin/HEAD
To remove all remotes/upstream
, try:
git for-each-ref refs/remotes/upstream --format="%(refname)" | while read ref;do
git update-ref -d ${ref}
done
git branches -a
is just telling you that you have a file locally in your .git
folder (created through git fetch
, at some point). Just remove it:
.git/refs/remotes/upstream/bugfix/corrupted-deb
To exemplify i created a small test project and created, manually, a file .git/refs/remotes/test/feature/mybranch
pointing to the sha of a single commit i made.
Running git branch -a
now yields:
/c/dev/remotetest (master)
$ git branch -a
* master
remotes/test/feature/mybranch
After removing the file .git/refs/remotes/test/feature/mybranch
running git branch -a
now yields:
/c/dev/remotetest (master)
$ git branch -a
* master
/Martin
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.