GIT: remove remote branches with no local tracking branch

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.

  • Git new file appears in all branches
  • teamcity action on branch delete
  • How to find out who delete a branch at git?
  • Perforce equivalent of git local commit
  • Will a commit be garbage collected if it's referred to by tag but not by branch?
  • Recreate Git Ref after Fatal Error
  • 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.

  • What are is most basic set of git command you would teach first?
  • Synchronize git workspace with another folder
  • “Pull is not possible because you have unmerged files” - how do I fix this?
  • TortoiseGit vs Git Extensions
  • Moving from Private GitHub Repo to Public and Private
  • Why doesn't git format-patch work for stashes?
  • 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?

    Git Baby is a git and github fan, let's start git clone.