Skip to content

Instantly share code, notes, and snippets.

@crakjie
Created November 23, 2015 18:03
Show Gist options
  • Save crakjie/7e4a7b924370b0ff944d to your computer and use it in GitHub Desktop.
Save crakjie/7e4a7b924370b0ff944d to your computer and use it in GitHub Desktop.
Delete each branch that already in the branch master. Put it in you path and you will have auto complete functionality of git.
#!/bin/bash
while read -r line
do
if [ "$line" != "origin/master" ] && [ "$line" != "origin/HEAD -> origin/master" ]
then
inMaster=$(git branch master --contains $line)
if [ "$inMaster" = " master" ] || [ "$inMaster" = "* master" ]
then
branchName=${line#origin/}
echo "$inMaster"
echo "$branchName"
echo "$line"
git push origin :$branchName
fi
fi
#echo "$line"
done < <(git branch -r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment