Home > front end >  Why does a deleted remote branch in git still show up when you do a 'git branch -a?
Why does a deleted remote branch in git still show up when you do a 'git branch -a?

Time:11-10

I'm trying to delete a branch on git both locally and remotely. And I think I've been successful. Thing is it still shows up remotely when I do a 'git branch -a'

I did this to delete it locally:

git branch -d branchToDelete

and this to delete it remotely:

git push origin --delete branchToDelete

I think I deleted it successfully on both ends.

If I do git pull branchToDelete

I get the following fatal: 'branchToDelete' does not appear to be a git repository fatal: Could not read from remote repository.

Which I thought means it no longer exists remotely?

But if I do

git branch -a

Then it still shows up in the list

remotes/origin/branchToDelete

So why does it keep showing up if it's deleted both locally and remotely?

And yes, the branch is/was named the same both locally and remotely.

Thanks much

CodePudding user response:

You need to do a git fetch -p to prune (remove) local tracking branches of remote branches that have been deleted.

  •  Tags:  
  • git
  • Related