Skip to content

Instantly share code, notes, and snippets.

@allartk
Last active March 28, 2022 14:05
Show Gist options
  • Select an option

  • Save allartk/d040e4f7d86b0cdeb08cb1eb5794d18d to your computer and use it in GitHub Desktop.

Select an option

Save allartk/d040e4f7d86b0cdeb08cb1eb5794d18d to your computer and use it in GitHub Desktop.
Branch cleanup
#!/bin/bash
echo -e "Current branch: \e[1m$(git rev-parse --abbrev-ref HEAD) \e[0m"
BRANCHES=`git branch --merged | egrep -v "(^\*|master|main|dev)"`
echo "Do you want to remove the following merged branches?"
echo $BRANCHES
echo "Are you sure? (y/n)"
read -n 1 answer
if([[ $answer != 'y' ]]); then
echo "Canceled"
exit
fi
git branch -d $BRANCHES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment