Let's say that git branch -a
outputs something like this:
- A
- B
- C
- *master
- remotes/origin/A
- remotes/origin/B
- remotes/origin/C
- remotes/origin/master
- remotes/origin/X
- remotes/origin/Y
- remotes/origin/Z
In bold are those branches (X, Y, Z) that are in the remote repository but I have not checked them out yet and I don't even intend to, they are related to a project I don't participate in.
Is there a command to remove all remote branches (those that are saved on MY repository, not the actual remote branch in the remote) which do not have a local tracking branch?
Edit: I intend to remove remote branches that are saved in my repository, showing the existence of the branch in the remote. I do not want to remove the actual branches in the remote.
Edit 2: Clarification in comment to mattmilten
You can recreate all remote branches with git pull
, but I don't always git pull
.
I often just git fetch origin master A B C
and then merge or rebase or do anything I want with branches master, A, B or C.
Point is, whenever I "git pull" (for some reason), all the branches I don't want are created and it seems I have no simple option to remove them afterwards.