Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anibalardid/0d2f31e169cdf9b6db2cb8585241406b to your computer and use it in GitHub Desktop.
Save anibalardid/0d2f31e169cdf9b6db2cb8585241406b to your computer and use it in GitHub Desktop.
Git Remove unused local branches

Prune local tracking branches that do not exist on remote anymore

git fetch -p ; git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment