Skip to content

Instantly share code, notes, and snippets.

@tgallacher
Last active March 27, 2019 01:17
Show Gist options
  • Save tgallacher/609c45f0251038fb70958e0ce98344f9 to your computer and use it in GitHub Desktop.
Save tgallacher/609c45f0251038fb70958e0ce98344f9 to your computer and use it in GitHub Desktop.
Git alias to prune branches
# Clean up branches which no longer exist on the remote
#
# @tip: Add to bash/zsh aliases
# @note: split over multiple lines to make it easier to read.
# @see: https://gist.github.com/tgallacher/cae12db973a235b52e9e5b014d21d633
git fetch && \
git remote prune origin && \
git branch -v | \
grep gone | \
awk '{print $1;}' | \
xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment