GIT: remove remote branches with no local tracking branch
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
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.
One Solution collect form web for “GIT: remove remote branches with no local tracking branch”
No, this is not possible. The information about (all) branches is a part of your repo and will always be copied when a new clone is created. You need to ignore these branches or simply run
git branch to list only your local branches.
How would you be able to retrieve remote branches at a later time, if you delete the information about their existence?