Skip to content

Instantly share code, notes, and snippets.

@chadxz
Created November 17, 2016 16:59
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 chadxz/7047442385b1b344ee173e055f425bd7 to your computer and use it in GitHub Desktop.
Save chadxz/7047442385b1b344ee173e055f425bd7 to your computer and use it in GitHub Desktop.
git-prunelocal
#!/bin/bash
#
# Prune local tracking branches that have been removed upstream.
# Your remote tracking branches can be removed automatically by setting `fetch.prune` to true or running `git fetch -prune`.
# Another command to clean up your remote tracking branches is `git remote prune <remote>`.
#
# Author: @leshill
# https://gist.github.com/leshill/9a1088a17f94cef24831
# Modifications by: @chadxz
if [[ $# = 1 && $1 == '-n' ]]; then
git branch -vv | grep ' gone]'
else
git branch -vv | grep ' gone]' | egrep -v '^\*' | cut -f 3 -d ' ' | xargs git branch -D
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment