Created
November 17, 2016 16:59
-
-
Save chadxz/7047442385b1b344ee173e055f425bd7 to your computer and use it in GitHub Desktop.
git-prunelocal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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