To expand on hobbs' comment, git fetch -p
(or git remote prune
or any similar command) only deletes, from your repository, each "remote branch" that is no longer present on the remote.
If you've made a local branch, that label won't go away unless you delete it manually.
For instance, suppose on remote origin
, there was a branch named sparkly
:
$ git fetch
...
* [new branch] sparkly -> origin/sparkly
You don't have a branch named sparkly
at this point (unless you already had one!); you only have origin/sparkly
(which lives in a separate name-space, refs/remotes/
rather than refs/heads/
).
If you created your own branch named sparkly
earlier, it probably does not track this new origin/sparkly
. If you create your own branch named sparkly
now, though, it will track origin/sparkly
.
In both cases, though, nothing will delete it automatically. You have to do that manually.
One reason why: there's no guarantee that just because origin/sparkly
has gone away, you are done with it ("it" being the local branch you created, which may or may not track this remote branch). If git deleted your label along with the origin/
version, any commits you had been working on might become very hard to find.
So, the short answer is: you'll have to do this manually (or semi-manually, you could automate it as much as you like). Use:
git branch -d sparkly
to delete it only if that's "safe" (in git's opinion :-) ), or:
git branch -D sparkly
to delete it even if git thinks this is "unsafe".