Reputation: 20145
When I
git branch -a | grep my_funny_branch
it gives
remotes/origin/my_funny_branch
But when I
git branch -d -r origin/my_funny_branch
it 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 do I delete that remote branch?
Thanks!
Upvotes: 5
Views: 7683
Reputation: 81
I had this exact problem. Solution for me was as follows:
git remote prune origin
and then
git fetch --prune
Ended up having a list of about 20 ghost branches pruned down to only what is actually a live branch
Upvotes: 8
Reputation: 54143
This error message is interesting:
error: bad ref for refs/remotes/origin/my_funny_branch
Looking at the Git source code, that message appears when Git is processing the reflog for that ref. It's possible the log is broken in some way, preventing various operations on the ref from completing successfully.
After backing it up, try deleting the log for that ref:
rm -rf .git/logs/refs/remotes/origin/my_funny_branch
and then see if you can delete the branch.
Upvotes: 14
Reputation: 14843
git update-ref -d refs/remotes/origin/my_funny_branch
If that doesn't work I would look for 'my_funny_branch' in your .git directory (probably .git/refs/remotes/origin) and see if there is something goofy with the file permissions.
Upvotes: 2
Reputation: 4538
Try running git remote prune origin
or git fetch origin --prune
Upvotes: 5