git fetch origin –prune doesn’t delete local branches?

The following command chain can be used to delete local branches:

git branch --v | grep "\[gone\]" | awk '{print $1}' | xargs git branch -D
  • git branch --v lists the local branches verbosely
  • grep "\[gone\]" finds all the branches whose remote branch is gone
  • awk '{print $1}' outputs only the name of the matching local branches
  • xargs git branch -D deletes all the matching local branches

This should work on MacOS as well as *nix environments.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)