Skip to content

Instantly share code, notes, and snippets.

@dep-deprecated
Created July 22, 2016 17:03
Show Gist options
  • Save dep-deprecated/e2f5e93ed9d3143ca503ac3b34a3e4bf to your computer and use it in GitHub Desktop.
Save dep-deprecated/e2f5e93ed9d3143ca503ac3b34a3e4bf to your computer and use it in GitHub Desktop.
Cleans a comma separated list of git branches from origin/locally
#! /bin/bash
if [[ -z "$2" ]]; then
echo 'Deletes remote and local branch(es)'
echo 'clean [remote] [feature,feature] (ex: clean origin tp1234,tp2345)'
else
read -p "Press [Enter] to perform the remote actions (CTRL-C to stop)..."
IFS=', ' read -a array <<< "$2"
git checkout master
for((i=0;i<${#array[@]};i++))
do
echo "Removing ${array[i]} from remote $1..."
git push $1 :${array[i]}
done
read -p "Press [Enter] to perform the local actions (CTRL-C to stop)..."
for((i=0;i<${#array[@]};i++))
do
echo "Deleting local branch ${array[i]}..."
git br -D ${array[i]}
vim ~/.todo -c /${array[i]}
done
cat ~/.todo && git branch
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment