How to remove the remote branch "ghost" in Git?

When I

git branch -a | grep my_funny_branch

He gives

remotes/origin/my_funny_branch

But when I

git branch -d -r origin/my_funny_branch

He gives

error: remote branch 'origin/my_funny_branch' not found

and when i just

git pull origin master

I get

git pull origin master
From ssh://example.com/foo/bar
 * branch            master     -> FETCH_HEAD
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
error: bad ref for refs/remotes/origin/my_funny_branch
error: bad ref for refs/remotes/origin/my_funny_branch
Counting objects: 47339, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16489/16489), done.
Writing objects: 100% (47339/47339), done.
Total 47339 (delta 30622), reused 47339 (delta 30622)
Rename from '.git/objects/pack/.tmp-7576-pack-15e7c5d209199f384b04dd820a8d625c658f7402.pack' to '.git/objects/pack/pack-15e7c5d209199f384b04dd820a8d625c658f7402.pack' failed. Should I try again? (y/n)

How to delete a remote branch?

Thank!

+4
source share
4 answers

This error message is interesting:

error: bad ref for refs/remotes/origin/my_funny_branch

Looking at the source code for Git, this message appears when Git processes the reflog for that ref. Perhaps the log is breaking somehow, which prevents the successful execution of various ref operations.

After backing up, try deleting the log for this link:

rm -rf .git/logs/refs/remotes/origin/my_funny_branch

and then see if the branch can be deleted.

+9
source

Try to run git remote prune originorgit fetch origin --prune

More here

+2
source
git update-ref -d refs/remotes/origin/my_funny_branch

, "my_funny_branch" .git(,.git/refs/remotes/origin) , - .

+2

?

git push origin :my_funny_branch
+1

All Articles