Skip to content

Instantly share code, notes, and snippets.

@eiberham
Last active July 13, 2020 00:26
Show Gist options
  • Save eiberham/0f6238417e64512f81c1f40759115b3e to your computer and use it in GitHub Desktop.
Save eiberham/0f6238417e64512f81c1f40759115b3e to your computer and use it in GitHub Desktop.
Keep your local repository clean
#!/bin/sh
# cleanup of local repository
set -e
echo "*** Listing branches already merged to develop *** \n"
git checkout develop > /dev/null 2>&1
BRANCHES=$(git branch --merged | grep -v develop | grep -v master)
echo "Branches to delete locally: \n"
echo $BRANCHES | tr ' ' '\n'
read -p "Do you wish to delete the listed branches ? [y/n] " RESP
if [ "$RESP" = "y" ]; then
echo $BRANCHES | while read branch; do
git branch -d $branch
done
else
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment