Last active
December 1, 2023 04:03
-
-
Save donnyquixotic/eb7eab6041cd9614348882313579b3ea to your computer and use it in GitHub Desktop.
creates git alias `sweep` to prune dead local 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
#!/bin/bash | |
# description: | |
# creates git alias 'sweep' that prunes all local branches merged | |
# into master and optionally, via -f flag, branches that have been merged into | |
# current branch. | |
# usage: `git sweep [-f]` | |
# create alias: | |
# copypasta script below and or save and run `chmod u+x $HOME/gitSweep.sh | . $HOME/gitSweep.sh` | |
git config --global alias.sweep \ | |
'!git branch --merged $([[ $1 != "-f" ]] && \ | |
git rev-parse master) | \ | |
egrep -v "(^\*|^\s*(master|develop|dev)$)" | \ | |
xargs git branch -d' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment