Skip to content

Instantly share code, notes, and snippets.

@Sanix-Darker
Created September 2, 2021 10:40
Show Gist options
  • Save Sanix-Darker/f93b7fc029fc82e37d53693eca8d8471 to your computer and use it in GitHub Desktop.
Save Sanix-Darker/f93b7fc029fc82e37d53693eca8d8471 to your computer and use it in GitHub Desktop.
tiny-branch-deletion.sh
#!/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