Last active
February 1, 2019 10:46
-
-
Save tkis/4dd747e3b84ee1bdc87fd530b5a963ad to your computer and use it in GitHub Desktop.
Git repo cleanup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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