Last active
October 22, 2022 10:58
-
-
Save KeKs0r/b48181fff4ecde695f92083349ddc557 to your computer and use it in GitHub Desktop.
Git Clean Branches
This file contains hidden or 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
# Delete branches that were deleted on remote | |
alias git.clean_remote_deleted='git fetch --all -p; git branch -vv | grep ": gone]" | awk '"'"'{ print $1 }'"'"' | xargs -n 1 git branch -D' | |
# Delete branches that have been merged into main/dev/prod/master | |
alias git.clean_locally_merged='git branch --merged | egrep -v "(^\*|main|master|dev|prod)" | xargs git branch -d' | |
alias git.clean='git.clean_remote_deleted && git.clean_locally_merged' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment