Delete branches listed by git branch -a

The command git branch -a lists a bunch of branches that are NOT on the repository, and NOT local branches. How can these be deleted?

* develop
  master
  remotes/origin/cloner

For example, remotes/origin/cloner used to exist in the repo, but it has since been deleted and I’d like it not to appear when typing git branch -a.

  • Showing just the (full) filenames that were changed in a revision
  • git merging branches in a bare repository
  • Run git commands on remote working tree (GIT_WORK_TREE=/path)
  • How to checkout a particular version in git from git log?
  • How to see an html page on github as a normal rendered html page to see preview in browser, without downloading?
  • Gerrit + GitLab's CI
  • github Diff Truncated error
  • Cannot push to github with Powershell
  • git clone vs copy paste, what's the difference?
  • Write GIT pre-commit hook in java?
  • Force Git to prompt for username and password
  • How to see exactly what happend in git merge
  • 4 Solutions collect form web for “Delete branches listed by git branch -a”

    If you have remote-tracking branches (such as origin/cloner in this case) which are left over after the corresponding branch has been deleted in the remote repository, you can delete all such remote-tracking branches with:

    git remote prune origin
    

    The documentation for git remote explains this as:

    Deletes all stale remote-tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in “remotes/<name>”.

    With --dry-run option, report what branches will be pruned, but do not actually prune them.

    To delete a branch which is not needed anymore you can use the following command :

    git branch -d -r origin/cloner
    

    You also do

    git push origin :cloner 
    

    To remove unwanted remote branches

    It may also happen that the remote repository reference has been deleted from the local clone, but still appears in the output of the ‘git branch -a’ command.
    In any case, you can always suppress any reference simply by deleting the corresponding files:

    $ rm -f .git/refs/remotes/cloner
    $ rm -rf .git/refs/remotes/deprecated_remote
    
    Git Baby is a git and github fan, let's start git clone.