Skip to content

Instantly share code, notes, and snippets.

@miyataka
Created July 14, 2022 10:32
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 miyataka/bcfba0ae1ab9d76c71e17e0d0c93d32d to your computer and use it in GitHub Desktop.
Save miyataka/bcfba0ae1ab9d76c71e17e0d0c93d32d to your computer and use it in GitHub Desktop.
git branch cleanup script
# c.f. https://blog.foresta.me/posts/git_useful_command_collection/
function git-cleanup() {
git branch --merged | egrep -v "\*|master|develop|main" | xargs git branch -D
git remote prune origin
git branch --format "%(refname:short) %(upstream:track)" | grep "\[gone\]" | awk '{print $1}' | xargs -IXXX git branch -D XXX
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment