Last active
March 23, 2018 11:20
-
-
Save MichaelAquilina/9d4d56204e29c7fea399a2b681dcee3c to your computer and use it in GitHub Desktop.
Automatically clean merged branches in a project
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
#!/usr/bin/env sh | |
delete_type="-d" | |
if [ "$1" = "-D" ];then | |
delete_type="-D" | |
fi | |
current="$(git rev-parse --abbrev-ref HEAD)" | |
git branch --merged "$current"| grep -v "$current" | while read -r branch; | |
do | |
git branch "$delete_type" "${branch}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save this as
git-clean-branches
somewhere in your $PATHyou can then clean your brances by simply running
git clean-branches