Created
September 19, 2024 12:34
-
-
Save gvannest/b7de82ef0000e65524f7dc43c3c9db8f to your computer and use it in GitHub Desktop.
Git aliases to clean git branches
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
[alias] | |
gone = "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f" | |
merged = "!f() { git branch --merged | egrep -v '(^\\*|master|main|dev)' | xargs git branch -D; }; f" | |
delete = "!f() { for branch in \"$@\"; do git branch -D \"$branch\" && git push origin --delete \"$branch\"; done; }; f" | |
# usage | |
# git gone => delete "gone" branches locally and remotely | |
# git merged => delete "merged: branches locally and remotely | |
# git delete branche-a branche-b branche-c => delete a, b and c branches locally and remotely |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment