Created
September 2, 2021 10:40
-
-
Save Sanix-Darker/f93b7fc029fc82e37d53693eca8d8471 to your computer and use it in GitHub Desktop.
tiny-branch-deletion.sh
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
#!/bin/bash | |
# by d4rk3r | |
# this function will loop over the list of branches you provided | |
# and if the branch name is upper than 2 | |
# it will delete it | |
# | |
# $1 can be a file_name or an <<EOF ... EOF | |
_del_branch_list(){ | |
for bb in $(cat $1); | |
do | |
if [ ${#bb} -ge 2 ]; | |
then | |
echo "[-] Deleting '$bb' branch..." | |
git branch -D "$bb" # we delete the branch | |
fi | |
done | |
} | |
# the main function | |
main(){ | |
echo "[-] Deleting locals branches is my job"! | |
_del_branch_list $1 | |
} | |
main $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment