Created
July 14, 2022 10:32
-
-
Save miyataka/bcfba0ae1ab9d76c71e17e0d0c93d32d to your computer and use it in GitHub Desktop.
git branch cleanup script
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
# 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