Skip to content

Instantly share code, notes, and snippets.

@tkis
Last active February 1, 2019 10:46
Show Gist options
  • Save tkis/4dd747e3b84ee1bdc87fd530b5a963ad to your computer and use it in GitHub Desktop.
Save tkis/4dd747e3b84ee1bdc87fd530b5a963ad to your computer and use it in GitHub Desktop.
Git repo cleanup
#!/bin/bash
read -p "Are you sure? (y/n) " -n 1
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
current_branch=`git rev-parse --abbrev-ref HEAD`
if [[ ${current_branch} != *"dev"* ]]; then
echo "Please checkout on dev branch first"
exit 1
fi
function clear_branches {
branches=`git branch | grep $1`
if [ -n "$branches" ]; then
git branch -D $branches
fi
}
clear_branches 'feat/'
clear_branches 'fix/'
clear_branches 'chore/'
git remote prune origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment