Skip to content

Instantly share code, notes, and snippets.

@garettmd
Last active February 1, 2019 15:37
Show Gist options
  • Save garettmd/e427bb3ef3786fb013f0398ad8a9f8d3 to your computer and use it in GitHub Desktop.
Save garettmd/e427bb3ef3786fb013f0398ad8a9f8d3 to your computer and use it in GitHub Desktop.
Clean up merged git branches in a project directory (use show_clean function first to see what will be removed)
function clean_merged() {
if [[ -z $1 ]]
then
BRANCH=master
else
BRANCH="$1"
fi
git branch --merged "${BRANCH}" | grep -Ev "${BRANCH}|master" | xargs -n 1 git branch -d
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment