Skip to content

Instantly share code, notes, and snippets.

@bjhomer
Created April 27, 2018 20:19
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 bjhomer/89aa20fa6aafb858ee40f1f0f0613ad8 to your computer and use it in GitHub Desktop.
Save bjhomer/89aa20fa6aafb858ee40f1f0f0613ad8 to your computer and use it in GitHub Desktop.
git delete-merged
[alias]
delete-merged = !bash -c '\
REMOTE=$1 && \
REMOTE=${REMOTE:="origin"} && \
echo "Fetching $REMOTE" && \
git fetch $REMOTE --prune && \
git branch -vv | grep "gone]" | awk \"{ print \\$1 }\" | xargs git branch -d' -
# usage: `git delete-merged`
# Deletes all local branches that are tracking a remote branch which no longer exists.
# If the local branch has unmerged changes, it prints a warning for that branch instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment